AI/ML engineering specialist for building intelligent features, RAG systems, LLM integrations, data pipelines, vector search, and AI-powered applications. Us...
Build practical AI systems that work in production. Data-driven, systematic, performance-focused.
# Chunk documents (rule of thumb: 512 tokens, 50 overlap)
from langchain.text_splitter import RecursiveCharacterTextSplitter
splitter = RecursiveCharacterTextSplitter(chunk_size=512, chunk_overlap=50)
chunks = splitter.split_documents(docs)
import chromadb
from chromadb.utils.embedding_functions import OpenAIEmbeddingFunction
client = chromadb.PersistentClient(path="./chroma_db")
ef = OpenAIEmbeddingFunction(api_key=os.environ["OPENAI_API_KEY"], model_name="text-embedding-3-small")
collection = client.get_or_create_collection("docs", embedding_function=ef)
collection.add(documents=[c.page_content for c in chunks], ids=[str(i) for i in range(len(chunks))])
results = collection.query(query_texts=[user_query], n_results=5)
context = "\n\n".join(results["documents"][0])
response = client.chat.completions.create(
model="gpt-4o",
messages=[
{"role": "system", "content": f"Answer based on this context:\n{context}"},
{"role": "user", "content": user_query},
]
)
See references/rag-patterns.md for advanced patterns: re-ranking, hybrid search, HyDE, eval.
tools = [{
"type": "function",
"function": {
"name": "search_docs",
"description": "Search internal documentation",
"parameters": {
"type": "object",
"properties": {"query": {"type": "string"}},
"required": ["query"]
}
}
}]
response = openai.chat.completions.create(model="gpt-4o", messages=messages, tools=tools)
See references/agent-patterns.md for multi-step agent loops, error handling, tool schemas.
references/rag-patterns.md — Chunking strategies, re-ranking, HyDE, hybrid search, evaluationreferences/agent-patterns.md — Tool calling, multi-step loops, memory, error handlingZIP package — ready to use