並び順

ブックマーク数

期間指定

  • から
  • まで

1 - 36 件 / 36件

新着順 人気順

python for loop if elif elseの検索結果1 - 36 件 / 36件

  • Pythonで理解するMCP(Model Context Protocol) | gihyo.jp

    動作環境 Python 3.12 ライブラリの使用バージョン gradio 5.34.2 anthropic 0.54.0 mcp 1.9.4 python-dotenv 1.1.0 仮想環境とライブラリインストール % cd mcp-host-with-gradio % python3 -m venv venv % source venv/bin/activate (venv) % pip install gradio anthropic mcp dotenv .envファイルの設定 AnthropicのAPIキーが必要です。APIキーの作成は以下を参考にしてください。APIの利用には料金がかかりますが、API従量課金であれば5ドルから始めることが可能です。 Claudeを使い始める -Anthropic .env ANTHROPIC_API_KEY=xxxxxxxxxxxxxxxxxx

      Pythonで理解するMCP(Model Context Protocol) | gihyo.jp
    • 遅くないpandasの書き方 - ML_BearのKaggleな日常

      これは何? この記事は Kaggle Advent Calendar 2021 の7日目の記事です。 pandasはデータ分析ライブラリとして非常に便利ですが、書き方を間違えると簡単に処理が遅くなってしまうという欠点があります。そこで、この記事では遅くならない書き方をするために気をつけたいポイントをいくつかご紹介したいと思います。 この Colab Notebookの実行結果をエクスポートした上で、不要な部分を一部削って記事にしています。colab notebook をコピーして実行してもらえれば再現することが可能なはずです。(colabにコメント等をいただいても返すことはできないと思います、すみません。) 前提条件 この記事ではあくまで「遅くない(なりづらい)書き方を紹介する」ことに努めます。よって、以下のような改善点はあるが一旦考慮の外におくものとして話を進めます。 並列化ライブラリ

        遅くないpandasの書き方 - ML_BearのKaggleな日常
      • PythonとRustの融合:PyO3/maturinを使ったPythonバインディングの作成入門 | gihyo.jp

        Cargo.tomlにはデフォルトのメタデータとPyO3の依存関係(バージョン)などが記載されています。また、pyproject.tomlにはビルドツールとしてmaturinが使用されることなどがあらかじめ定義されています。 注目すべきはRustスクリプトを記述するsrc/lib.rsファイルです。以下のようなscaffold(足場)が最初から記載されています。 src/lib.rsにデフォルトで記載されているscaffold 1 use pyo3::prelude::*; 2 3 /// Formats the sum of two numbers as string. 4 #[pyfunction] 5 fn sum_as_string(a: usize, b: usize) -> PyResult<String> { 6 Ok((a + b).to_string()) 7 } 8 9

          PythonとRustの融合:PyO3/maturinを使ったPythonバインディングの作成入門 | gihyo.jp
        • AWS Documentation MCP Server でAWSのFAQアシスタントを作成する - Taste of Tech Topics

          はじめに データ分析エンジニアの木介です。 AWSの公式ドキュメントで欲しい情報を探そうとしても、なかなか目的のページが見つからなかったりすることってありませんか? AWSから「AWS Documentation MCP Server」が公開されたため、本記事では、それを利用して、最新のAWSドキュメントに基づき、質問に回答してくれるFAQアシスタントの作成方法について紹介したいと思います。 MCP Serverの呼び出しには、Claude Desktop および dolphin-mcp を利用します。 github.com はじめに 概要 1. MCPとは MCPのしくみ 2. AWS Documentation MCP Serverとは Claude Desktop経由でAWS ドキュメントのFAQアシスタントを作成する dolphin-mcpでAWS ドキュメントのFAQアシスタント

            AWS Documentation MCP Server でAWSのFAQアシスタントを作成する - Taste of Tech Topics
          • GPT in 60 Lines of NumPy | Jay Mody

            January 30, 2023 In this post, we'll implement a GPT from scratch in just 60 lines of numpy. We'll then load the trained GPT-2 model weights released by OpenAI into our implementation and generate some text. Note: This post assumes familiarity with Python, NumPy, and some basic experience with neural networks. This implementation is for educational purposes, so it's missing lots of features/improv

            • Writing a C compiler in 500 lines of Python

              A few months ago, I set myself the challenge of writing a C compiler in 500 lines of Python1, after writing my SDF donut post. How hard could it be? The answer was, pretty hard, even when dropping quite a few features. But it was also pretty interesting, and the result is surprisingly functional and not too hard to understand! There's too much code for me to comprehensively cover in a single blog

              • ChatGPT (Advanced Data Analysis)でBNF式からパーサーを生成する - Taste of Tech Topics

                こんにちは、最近ピアノを習い始めた安部です。 今回は、ChatGPTのAdvanced Data Analysis (旧Code Interpreter)にBNF式を与えてパーサーを作成してもらおうと思います。 BNF式のように機械的に解釈可能なものであれば、正確にコードを生成してくれるのではないでしょうか? BNFでうまくいけば、その他の様々な形式のデータやフォーマットからパーサーを自動生成してくれることが期待できそうです。 1. BNFとは BNF(バッカス・ナウア記法)とは、プログラムの構文規則(文脈自由文法)を記述するための記法です。 正確な定義よりも具体例を見た方が早く理解できると思うので、例を示します。 『プログラム意味論』(横内寛文 著)の冒頭に登場する、非常に単純なプログラムを許容する言語の定義です。 <変数> ::= A | B | C | ... | Z <定数> ::

                  ChatGPT (Advanced Data Analysis)でBNF式からパーサーを生成する - Taste of Tech Topics
                • ChatGPT Retrieval Pluginに任意のベクトル検索エンジンProviderを実装する - エムスリーテックブログ

                  Overview エムスリーエンジニアリンググループ AI・機械学習チームでソフトウェアエンジニアをしている中村(po3rin) です。検索とGoが好きです。 エムスリーではChatGPTの可能性にいち早く注目して活用を検討している段階ですが、本格的なデータ投入にはまだ懸念もあり、セキュリティチームと検討を進めている段階です。 そんな中で個人または組織のドキュメントのセマンティック検索と取得を可能にするChatGPTプラグイン「ChatGPT Retrieval Plugin」が登場しました。 github.com 情報検索好きとしては黙っていられず、外部公開用のエムスリーAI・機械学習チームのメンバー紹介ドキュメントを使ってローカルで試してみました。 # 用意したドキュメント 中村弘武は東京都在住で、エムスリーという企業で働いでいます。 エムスリーの検索基盤を主に担当しています。また、書

                    ChatGPT Retrieval Pluginに任意のベクトル検索エンジンProviderを実装する - エムスリーテックブログ
                  • Python 3.13 gets a JIT

                    Happy New Year everyone! In late December 2023 (Christmas Day to be precise), CPython core developer Brandt Bucher submitted a little pull-request to the Python 3.13 branch adding a JIT compiler. This change, once accepted would be one of the biggest changes to the CPython Interpreter since the Specializing Adaptive Interpreter added in Python 3.11 (which was also from Brandt along with Mark Shann

                      Python 3.13 gets a JIT
                    • openai/gpt-oss-120b · Hugging Face

                      ","eos_token":"<|return|>","pad_token":"<|endoftext|>"},"chat_template_jinja":"{#-\n In addition to the normal inputs of `messages` and `tools`, this template also accepts the\n following kwargs:\n - \"builtin_tools\": A list, can contain \"browser\" and/or \"python\".\n - \"model_identity\": A string that optionally describes the model identity.\n - \"reasoning_effort\": A string that describes t

                        openai/gpt-oss-120b · Hugging Face
                      • 4 Pandas Anti-Patterns to Avoid and How to Fix Them

                        pandas is a powerful data analysis library with a rich API that offers multiple ways to perform any given data manipulation task. Some of these approaches are better than others, and pandas users often learn suboptimal coding practices that become their default workflows. This post highlights four common pandas anti-patterns and outlines a complementary set of techniques that you should use instea

                          4 Pandas Anti-Patterns to Avoid and How to Fix Them
                        • CohereLabs/c4ai-command-r-plus · Hugging Face

                          ","chat_template":[{"name":"default","template":"{{ bos_token }}{% if messages[0]['role'] == 'system' %}{% set loop_messages = messages[1:] %}{% set system_message = messages[0]['content'] %}{% elif false == true %}{% set loop_messages = messages %}{% set system_message = 'You are Command-R, a brilliant, sophisticated, AI-assistant trained to assist human users by providing thorough responses. You

                            CohereLabs/c4ai-command-r-plus · Hugging Face
                          • Implementing Logic Programming

                            Most of my readers are probably familiar with procedural programming, object-oriented programming (OOP), and functional programming (FP). The majority of top programming languages on all of the language popularity charts (like TIOBE) support all three to some extent. Even if a programmer avoided one or more of those three paradigms like the plague, they’re likely at least aware of them and what th

                              Implementing Logic Programming
                            • Building a Toy Programming Language in Python

                              I thought it would be fun to go outside of my comfort zone of web development topics and write about something completely different and new, something I have never written about before. So today, I'm going to show you how to implement a programming language! The project will parse and execute programs written in a simple language I called my (I know it's a lame name, but hey, it is "my" language).

                                Building a Toy Programming Language in Python
                              • LLM音声対話システムの応答を高速化してみた | CyberAgent Developers Blog

                                はじめまして、CyberAgent AI Lab Intaractive Agentチームの技術研究員の大平といいます。 この記事は CyberAgent Developers Advent Calendar 2023 1日目の記事です。 ChatGPTの登場以降、自然なチャット対話はAPI呼び出しだけで簡単に実装できるようになりました。 更に人間のようなインタラクションを実現しようとすれば、音声対話に発展させたいと思う方も多いかと思われます。 しかし実際にLLMを使って音声対話システムを構築してみると、そのレスポンスの遅さに不満を感じることになります。 この記事ではよくあるシンプルなLLMを用いた音声対話に対していくつかの工夫を施し、その応答速度をできるだけ早めてみようという試みになります。 よくある構成として、以下を用います。 音声認識 Google STT LLM ChatGPT 3

                                  LLM音声対話システムの応答を高速化してみた | CyberAgent Developers Blog
                                • python_modules.pdf

                                  Python3 OpenCV / Pillow / pygame / Eel / PyDub / NumPy / matplotlib / SciPy / SymPy / gmpy2 / hashlib, passlib / Cython / Numba / ctypes / PyInstaller / curses / tqdm / JupyterLab / json / psutil / urllib / zenhan / jaconv Copyright © 2017-2025, Katsunori Nakamura 2025 8 19 Python ‘ .py’ Python Python Windows PSF Python py .py Enter macOS Linux PSF Python python3 .py Enter Anaconda Prompt Python p

                                  • SESでバウンスメールを確認する方法をいくつか試してみた | DevelopersIO

                                    こんにちは、コンサル部@大阪オフィスのTodaです。 Amazon Simple Email Service(以降SES)は任意のアプリケーションからメール配信をする際、おすすめのサービスになります。 メール配信はエンドユーザ様から指定頂いた、メールアドレスに対しておこないますが、入力ミスによる受信失敗(バウンスメール)、迷惑メール報告(苦情メール)が発生する場合があり管理が必要になります。 今回は、簡易に運営者側でバウンスメールに気づける方法を試してみます。 バウンスメール対策の重要性 SESではサービスを利用して送信したメールの中でバウンスメールと苦情メールの計測をしており、一定以上になった場合、レビュー対象や配信の停止がおこなわれます。処理を維持をするためバウンスメールの対応が必要になります。 ■ バウンスに関するよくある質問 から引用 https://docs.aws.amazon

                                      SESでバウンスメールを確認する方法をいくつか試してみた | DevelopersIO
                                    • My thoughts on writing a Minecraft server from scratch (in Bash)

                                      My thoughts on writing a Minecraft server from scratch (in Bash) For the past year or so, I've been thinking about writing a Minecraft server in Bash as a thought excercise. I once tried that before with the Classic protocol (the one from 2009), but I quickly realized there wasn't really a way to properly parse binary data in bash. Take the following code sample: function a() { read -n 2 uwu echo

                                      • ​Getting Started with Python

                                        Python is a powerful programming language that provides many packages that we can use. Using the versatile Python programming language, we can develop the following: AutomationDesktop applicationAndroidWebIoT home automationData Science and the list goes on.In this article, our primary focus will be knowing how to start learning Python and the essentials required to be a data scientist. Below is t

                                          ​Getting Started with Python
                                        • openai/gpt-oss-20b · Hugging Face

                                          ","eos_token":"<|return|>","pad_token":"<|endoftext|>"},"chat_template_jinja":"{#-\n In addition to the normal inputs of `messages` and `tools`, this template also accepts the\n following kwargs:\n - \"builtin_tools\": A list, can contain \"browser\" and/or \"python\".\n - \"model_identity\": A string that optionally describes the model identity.\n - \"reasoning_effort\": A string that describes t

                                            openai/gpt-oss-20b · Hugging Face
                                          • Rust on MIPS64 Windows NT 4.0

                                            Introduction Some part of me has always been fascinated with coercing code to run in weird places. I scratch this itch a lot with my security research projects. These often lead me to writing shellcode to run in kernels or embedded hardware, sometimes with the only way being through an existing bug. For those not familiar, shellcode is honestly hard to describe. I don’t know if there’s a very form

                                              Rust on MIPS64 Windows NT 4.0
                                            • [Ansible] そのtag設定、想定通りに動いてますか? (継承機能とその実装を確認する) - zaki work log

                                              playbook内のtask定義にtagを設定しておくことで、指定tagのtaskのみ実行したり、逆に指定tagのtaskを除外してansible-playbookを実行することができます。 開発中のtaskのみピンポイントで実行したい場合や、逆に、共有のDBのデータを更新したりするtaskはほかのユーザーやチームと調整してからでないと実行が難しかったり、Blue-Greenデプロイメントの実装で環境Aの機能をオフにしてもう片方の環境Bをオンにするような処理だけど開発中は環境Bだけ確認したかったり、大量データのダウンロードや冪等の確認を伴い処理に時間がかかるため開発中は実行したくないなど特定のtaskは実行したくない場合に利用できます。 また、特殊tagとして、常に実行するalwaysと実行しないneverというtagが予約語として用意されています。 neverは特に「通常は実行したくない

                                                [Ansible] そのtag設定、想定通りに動いてますか? (継承機能とその実装を確認する) - zaki work log
                                              • Basic Music Theory in ~200 Lines of Python | Manohar Vanga

                                                Note: all the code for this article can be found here as a Github gist. There’s also a nice discussion on Hacker News with lots of comments that might be of interest. I’m a self-taught guitarist of many years, and like a lot of self-taught musicians, am woefully inept at (Western) music theory. So naturally, I decided to write some code. This article explains the very basics of Western music theor

                                                  Basic Music Theory in ~200 Lines of Python | Manohar Vanga
                                                • Raspberry Pi Pico W で Httpサーバ(microdot)とセンサーによるHTTPリクエスト機能を同時に稼働させる

                                                  Raspberry Pi Pico W で Httpサーバ(microdot)とセンサーによるHTTPリクエスト機能を同時に稼働させる Raspberry Pi Pico W が発表されました。日本ではまだ未発売ですが、技適は取得されたようですので近いうちに国内販売がされそうです。 試しに、Webサーバ ( Microdot )とWebクライアント(urequest) を uasyncio で並列実行するコードを書きましたので、紹介します。 今回作成したコードや動作している動画は、Github で公開しています。 ytyng/rpi-pico-w-webserver-and-client: Raspberry Pi Pico W webserver and client sample code Raspberry Pi Pico W とは コストパフォーマンスが高いマイクロコントローラです

                                                    Raspberry Pi Pico W で Httpサーバ(microdot)とセンサーによるHTTPリクエスト機能を同時に稼働させる
                                                  • Vim9 script for Python Developers · GitHub

                                                    vim9script4pythondevelopers.md Vim9 script for Python Developers Vim9 script�Vim script��������������������������������������������������系��� def������義����������Vim script��vim9script�����使����������(vim9script���

                                                      Vim9 script for Python Developers · GitHub
                                                    • 同時タイムラプスのGUIをpythonでつくってみた - Qiita

                                                      import PySimpleGUI as sg import datetime import time import os import numpy as np import cv2 import glob from time import sleep mport schedule import mojimoji import sys # class def cam_2(create_directory1,create_directory2): # global create_directory1 cap1 = cv2.VideoCapture(1,cv2.CAP_DSHOW) time.sleep(1) cap1.set(cv2.CAP_PROP_EXPOSURE,-6) ret1, frame1 = cap1.read() print(ret1) if ret1 == False:

                                                        同時タイムラプスのGUIをpythonでつくってみた - Qiita
                                                      • 12 Languages in 12 Months

                                                        I stumbled across Exercism last year and was immediately charmed. It's a website devoted to teaching programming languages. It's got a great UI, offers free mentoring (by a human!), and is entirely open source. Last January, they announced a new program called 12in23, where they challenged participants to try 12 new programming languages in 2023. Each month would have a theme (such as "Analytical

                                                          12 Languages in 12 Months
                                                        • Python behind the scenes #11: how the Python import system works

                                                          If you ask me to name the most misunderstood aspect of Python, I will answer without a second thought: the Python import system. Just remember how many times you used relative imports and got something like ImportError: attempted relative import with no known parent package; or tried to figure out how to structure a project so that all the imports work correctly; or hacked sys.path when you couldn

                                                          • A Deep Dive into eBPF: Writing an Efficient DNS Monitoring.

                                                            eBPF / XDP is an in-kernel virtual machine, provides a high-level library, instruction set and an execution environment inside the Linux kernel. It’s used in many Linux kernel subsystems, most prominently networking, tracing, debugging and security. Including to modify the processing of packets in the kernel and also allows the programming of network devices such as SmartNICs. Use cases in eBPF im

                                                              A Deep Dive into eBPF: Writing an Efficient DNS Monitoring.
                                                            • はじめての自然言語処理 ELECTRA(BERT の事前学習手法の改良)による固有表現抽出の検証 | オブジェクトの広場

                                                              今回は BERT における事前学習の改良手法である ELECTRA の検証です。ELECTRA はモデルサイズ、データ、計算量が同一条件であればオリジナルの BERT を凌ぐ性能とのことなので結果が楽しみなところです。事前学習をした後のファインチューニングは、いつも livedoor News Corpus の文書分類ばかりだったので、今回は固有表現抽出を試すことにしました。 1. はじめに 今回は BERT における事前学習の改良手法である ELECTRA 1 の検証です。 BERT に関しては 第3回 で取り上げていますが、トークン化が Sentencepiece である為、トークン単位での処理に難がありました2。今回は ELECTRA を試すにあたり、そのあたりの対応も入れ、 Megagon Labs さんから公開されている UD_Japanese-GSD v2.6-NE 3 を使っ

                                                                はじめての自然言語処理 ELECTRA(BERT の事前学習手法の改良)による固有表現抽出の検証 | オブジェクトの広場
                                                              • AHC001で奇想の浮世絵師「歌川国芳」の絵を再現する - Qiita

                                                                Deleted articles cannot be recovered. Draft of this article would be also deleted. Are you sure you want to delete this article? はじめに 突然ですが、皆さんは歌川国芳という浮世絵師をご存じでしょうか? 「国芳? 広重ではなくて?」と思われる方もいらっしゃるかも知れません。 歌川広重は「東海道五十三次」などの作品で名が知られた、歌川派を代表する江戸時代の浮世絵師です。 『東海道五十三次』より「日本橋」(本画像を含め、浮世絵は全てwikiより拝借しました。) 一方の歌川国芳は、あまり世間に知られた名前ではないかも知れません。 国芳は、寛政9年(1797)に江戸日本橋で生まれ、文久元年(1861)に没した浮世絵師で、広重とはほぼ同時代に活躍しました。歌川派の初代、歌川

                                                                  AHC001で奇想の浮世絵師「歌川国芳」の絵を再現する - Qiita
                                                                • JSON is not JSON Across Languages | Dochia CLI Blog

                                                                  Introduction: These Aren’t the JSONs You’re Looking For JSON (JavaScript Object Notation) was designed as a simple, lightweight, and human-readable data interchange format, often positioned as a more accessible alternative to XML. It has become the de facto standard for web APIs and system integration. However, while the specification itself is straightforward, different programming languages and

                                                                    JSON is not JSON Across Languages | Dochia CLI Blog
                                                                  • Python behind the scenes #12: how async/await works in Python

                                                                    Mark functions as async. Call them with await. All of a sudden, your program becomes asynchronous – it can do useful things while it waits for other things, such as I/O operations, to complete. Code written in the async/await style looks like regular synchronous code but works very differently. To understand how it works, one should be familiar with many non-trivial concepts including concurrency,

                                                                    • Why F#?

                                                                      Hacker. Emacs fanatic. Lover of parentheses. Firebrand. Just another programmer with too many opinions. I’m not the best, but I’m pretty good. If someone had told me a few months ago I’d be playing with .NET again after a 15+ years hiatus I probably would have laughed at this.1 Early on in my career I played with .NET and Java, and even though .NET had done some things better than Java (as it had

                                                                        Why F#?
                                                                      • VLAモデル「π0」のファインチューニングと推論入門 with LeRobot + Gymnasium - ABEJA Tech Blog

                                                                        こんにちは!ABEJA で ABEJA Platform 開発を行っている坂井(@Yagami360)です。 先日の記事で、ロボティクス領域の VLA モデル「π0」の内部の仕組みを解説しました。 tech-blog.abeja.asia 今回の記事では、この「π0」を LeRobot を使用して実際に動かしてます。(π0 を動かす分には、中身の仕組みは必ずしも知らなくても十分なので↑の記事はスキップしてもらってもOKです。) とはいえ、いきなり実機で動かすのは色々ハードルがあるので、この記事では Gymnasium でのシミュレーター環境上で動かしたり(推論させたり)、ファインチューニングしたりする方法を解説します。 使用ライブラリ LeRobot とは? Gymnasium とは? 環境構築方法 pushT シミュレーター環境上でπ0を動かす 学習用データセット モデルのファインチュー

                                                                          VLAモデル「π0」のファインチューニングと推論入門 with LeRobot + Gymnasium - ABEJA Tech Blog
                                                                        • Following up on the Python JIT

                                                                          Performance of Python programs has been a major focus of development for the language over the last five years or so; the Faster CPython project has been a big part of that effort. One of its subprojects is to add an experimental just-in-time (JIT) compiler to the language; at last year's PyCon US, project member Brandt Bucher gave an introduction to the copy-and-patch JIT compiler. At PyCon US 20

                                                                          1