agentleFS
lauren-frameworklauren-framework/lauren-ai/skills/embedding-model-ingestion/SKILL.md

embedding-model-ingestion

Skill0 starsChanged 6 months agoMITView on GitHub

Handles embedding model selection and batch document ingestion into vector stores. Use when processing large document corpora efficiently, swapping embedding models (OpenAI, Cohere, local), batching API calls to avoid rate limits, or building ingestion pipelines.

The file

We split this skill into the rules it gives an agent

2 rules. About 0 are common, 2 are distinctive, and 0 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈2

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Use a simple deterministic embedding function in tests to avoid network calls:

    line 81
  2. Distinctive:

    Always chunk large documents before embedding to stay within model context windows:

    line 93

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Use codemap find "SymbolName" to locate any symbol before reading — it gives exact file + line range and is faster than grep across the whole repo.

Embedding Model Selection & Batch Ingestion

Overview

The built-in InMemoryVectorStore uses TF-IDF (no external embeddings needed). For production use cases, you can provide pre-computed embeddings via the embedding= parameter on upsert(), or supply a batch embedding function to your ingestion pipeline.


Batch ingestion pattern

from lauren_ai._knowledge import KnowledgeBase, TextLoader, FixedSizeChunker
from lauren_ai._memory._vector import InMemoryVectorStore

async def batch_ingest(
    kb: KnowledgeBase,
    documents: list[str],
    batch_size: int = 10,
) -> int:
    """Ingest documents in batches, returning total chunks indexed."""
    total = 0
    for i in range(0, len(documents), batch_size):
        batch = documents[i : i + batch_size]
        for text in batch:
            count = await kb.load(TextLoader(text, is_file=False))
            total += count
    return total

Providing a custom embedding function

Replace the default TF-IDF with dense embeddings from any provider by passing embedding= to store.upsert():

from openai import AsyncOpenAI

client = AsyncOpenAI()

async def embed(texts: list[str]) -> list[list[float]]:
    resp = await client.embeddings.create(model="text-embedding-3-small", input=texts)
    return [item.embedding for item in resp.data]

store = InMemoryVectorStore()
embeddings = await embed(["Python is a language", "JavaScript runs in browsers"])
for text, vec in zip(texts, embeddings):
    await store.upsert(text, embedding=vec)

Cohere embed API

import cohere

co = cohere.AsyncClient()

async def cohere_embed(texts: list[str]) -> list[list[float]]:
    resp = await co.embed(texts=texts, model="embed-english-v3.0", input_type="search_document")
    return resp.embeddings

Mock embedding for tests

Use a simple deterministic embedding function in tests to avoid network calls:

def mock_embed_fn(texts: list[str]) -> list[list[float]]:
    """Produce a 128-d vector from word count (deterministic, no API)."""
    return [[len(t.split()) * 0.1] * 128 for t in texts]

Chunking before embedding

Always chunk large documents before embedding to stay within model context windows:

chunker = FixedSizeChunker(chunk_size=512, overlap=64)
kb = KnowledgeBase(store=InMemoryVectorStore(), chunker=chunker)
await kb.load(TextLoader("docs/large_manual.txt"))

Batch size tuning

ProviderRecommended batch_sizeNotes
OpenAI text-embedding-3-small100Max 2048 input texts per request
Cohere embed-english-v3.096Max 96 texts per request
Local models32–64Depends on GPU memory

Reference

  • lauren_ai._knowledge: KnowledgeBase, TextLoader, FixedSizeChunker
  • lauren_ai._memory._vector: InMemoryVectorStore
  • Skills: rag-pipeline, vector-store-integration

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.