Python guides
Every published Python guide, newest first, with practical examples you can copy into your own project.
3,965 guides across 14 topics
Topics
Popular Python guides
Most readLatest Python guides
Page 32 of 179How to Stream OpenAI Chat Completions in Python
Learn how to stream OpenAI chat completions in Python, handle token chunks, manage errors, and use async streaming for real-time responses.
Python OpenAI Tool Calling and Function Calling
python openai tool calling and function calling: Implement OpenAI tool calling in Python: define tool schemas, detect tool_calls in responses, execute functions, and r...
Python OpenAI Structured Outputs with JSON Schema
Learn how to use OpenAI structured outputs in Python to enforce a JSON schema on model responses, parse the returned JSON, and validate it with Pydantic.
Python OpenAI Responses API for Text Generation
python openai responses api text generation: Learn how to use the OpenAI Responses API in Python for text generation, including request parameters, response handling,...
Python OpenAI Responses API Usage: Practical Examples
Learn how to use the OpenAI Responses API from Python: making requests, handling responses, streaming, error handling, and production considerations.
How to Normalize Embeddings with Python Sentence Transformers
python sentence transformers normalize embeddings: Learn how to normalize embeddings from Python sentence-transformers for cosine similarity, including the normalize_e...
Python Sentence Transformers Batch Encoding and GPU
Learn how to batch encode texts with sentence-transformers on a GPU, control batch size, avoid out-of-memory errors, and choose the right output format for embeddings.
Python Sentence Transformers: Cosine Similarity and Semantic Search
Learn how to use Python sentence transformers and cosine similarity to build semantic search. Covers model loading, embeddings, similarity scoring, vector indexes, and practical trade-offs.
Python Sentence Transformers: Embeddings and Semantic Similarity
Learn how to generate sentence embeddings with Python's sentence-transformers library and compute semantic similarity with cosine similarity. The article also covers model selection, batching, and production considerations.
Fine-Tuning with Python Transformers Trainer and TrainingArguments
python transformers trainer trainingarguments and fine tuning: Learn how to fine-tune transformer models with the Python transformers Trainer and TrainingArguments, co...