GitRAG Embedder: Git Repository to Embeddings Pipeline
🚀 Overview
GitRAG Embedder is a focused library that converts Git repositories into embedding vectors. Pure processing pipeline - from repository cloning to embedding generation.
✨ Features
🔍 Repository Processing
- Git Integration: Clone and process any Git repository
- Multi-Format Support: Process
.py,.md,.rst,.txtfiles - Smart Chunking: Configurable text splitting with overlap
- Selective Processing: Filter by file type and directory
- Batch Processing: Efficient handling of large codebases
📊 Multiple Embedding Backends
- OpenAI Embeddings: Support for text-embedding-ada-002, text-embedding-3-small/large
- Sentence Transformers: Local models like all-MiniLM-L6-v2
- HuggingFace Transformers: Custom transformer models
- Batch Processing: Efficient batch embedding generation
- Automatic Retries: Built-in error handling and retries
📦 Installation
pip install git-rag-embedder
Optional dependencies (install as needed):
# For OpenAI embeddings
pip install openai
# For Sentence Transformers
pip install sentence-transformers
# For HuggingFace embeddings
pip install transformers torch
🚀 Quick Start
Basic Usage
from git_rag_embedder import GitRAGEmbedder
# Initialize with default settings (Sentence Transformers)
embedder = GitRAGEmbedder()
# Process a repository into embeddings
embeddings = embedder.process_repository(
"https://github.com/username/repository"
)
print(f"Generated {len(embeddings)} embedding vectors")
Using Different Backends
# OpenAI embeddings
embedder = GitRAGEmbedder(
embedding_backend="openai",
model="text-embedding-3-small",
api_key="your-openai-key"
)
# Sentence Transformers
embedder = GitRAGEmbedder(
embedding_backend="sentence_transformers",
model_name="all-MiniLM-L6-v2"
)
# HuggingFace Transformers
embedder = GitRAGEmbedder(
embedding_backend="huggingface",
model_name="sentence-transformers/all-MiniLM-L6-v2"
)
Advanced Configuration
embeddings = embedder.process_repository(
repo_url="https://github.com/username/repository",
chunk_size=1000,
chunk_overlap=150,
extensions={'.py', '.md', '.txt'},
exclude_dirs={'tests', 'docs', 'node_modules'},
batch_size=32,
max_files=1000
)
⚙️ Configuration
Processing Parameters
# All configuration options
embeddings = embedder.process_repository(
repo_url="https://github.com/user/repo", # Git URL or local path
chunk_size=1000, # Characters per chunk
chunk_overlap=150, # Overlap between chunks
extensions={'.py', '.md'}, # File types to process
exclude_dirs={'tests'}, # Directories to skip
batch_size=32, # Processing batch size
max_files=1000 # Maximum files to process
)
Available Embedding Models
OpenAI Models:
text-embedding-ada-002(1536 dim)text-embedding-3-small(1536 dim)text-embedding-3-large(3072 dim)
Sentence Transformers Models:
all-MiniLM-L6-v2(384 dim)all-mpnet-base-v2(768 dim)multi-qa-mpnet-base-dot-v1(768 dim)
HuggingFace Models:
- Any sentence transformer compatible model
📊 Output Format
Embedding Structure
Each embedding contains:
{
'content': 'def calculate_sum(a, b):\n return a + b',
'file_path': 'src/math_utils.py',
'file_extension': '.py',
'embedding': [0.123, -0.456, 0.789, ...], # Vector array
'embedding_dimension': 384,
'embedding_model': 'sentence_transformers',
'embedding_norm': 1.234, # L2 norm of the vector
'metadata': {
'chunk_size': 245,
'token_count': 45
}
}
🔧 API Reference
GitRAGEmbedder Class
class GitRAGEmbedder:
def __init__(
self,
embedding_backend: str = "sentence_transformers",
**backend_kwargs
)
def process_repository(
self,
repo_url: str,
chunk_size: int = 1000,
chunk_overlap: int = 150,
extensions: Set[str] = None,
exclude_dirs: Set[str] = None,
batch_size: int = 32,
max_files: int = 1000
) -> List[Dict[str, Any]]
EmbeddingGenerator Class
class EmbeddingGenerator:
def __init__(self, backend: str = "sentence_transformers", **backend_kwargs)
def generate_embeddings(
self,
chunks: List[Dict[str, Any]],
batch_size: int = 32,
max_retries: int = 3
) -> List[Dict[str, Any]]
def embed_single_text(self, text: str) -> List[float]
def get_embedding_dimension(self) -> int
Available Backends
OpenAIEmbeddingBackend- For OpenAI embedding APISentenceTransformersBackend- For local sentence transformer modelsHuggingFaceEmbeddingBackend- For HuggingFace transformer models
🏗️ Advanced Usage
Custom Processing Pipeline
from git_rag_embedder import GitRAGEmbedder, EmbeddingGenerator
# Step-by-step processing
embedder = GitRAGEmbedder()
# Extract and chunk documents
documents = embedder.extract_documents("https://github.com/user/repo")
# Use different embedding backend for generation
embedding_gen = EmbeddingGenerator(
backend="openai",
model="text-embedding-3-small",
api_key="your-key"
)
embeddings = embedding_gen.generate_embeddings(documents)
Multiple Repositories
repositories = [
"https://github.com/org/repo1",
"https://github.com/org/repo2",
"/path/to/local/repo"
]
all_embeddings = []
for repo in repositories:
embeddings = embedder.process_repository(repo)
all_embeddings.extend(embeddings)
Save/Load Embeddings
# Save for later use
embedder.save_embeddings(embeddings, "my_embeddings.json")
# Load saved embeddings
loaded_embeddings = embedder.load_embeddings("my_embeddings.json")
🔍 Backend Details
OpenAI Backend
backend = OpenAIEmbeddingBackend(
api_key="your-key", # Optional, uses OPENAI_API_KEY env var
model="text-embedding-3-small"
)
Sentence Transformers Backend
backend = SentenceTransformersBackend(
model_name="all-MiniLM-L6-v2" # Any sentence-transformers model
)
HuggingFace Backend
backend = HuggingFaceEmbeddingBackend(
model_name="sentence-transformers/all-MiniLM-L6-v2" # Any HF model
)
📝 License
MIT License - see LICENSE file for details.
📞 Support
- Issues: GitHub Issues
Focus: Pure Git repository to embedding conversion pipeline. No search, no quality metrics, just embeddings.
Star this repository if you find it helpful! ⭐
Metadata
Release files for git-rag-embedder 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| git_rag_embedder-0.1.1.tar.gz | 15.3 kB | With provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| git_rag_embedder-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 31.0 kB
Release files / git_rag_embedder-0.1.1.tar.gz
| Download URL | git_rag_embedder-0.1.1.tar.gz |
|---|---|
| Size | 15.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6954afcc51655c2aedddc6502c39160f72a0164f91d16ecb3c69e009052f9a9b
|
|
BLAKE2b-256 checksum How to use checksums |
031dfe958609489b1c42e1e012a50c0b134f28fb0cb0f9f3ef178044943ee045
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 7, 2025.
Transparency logRelease files / git_rag_embedder-0.1.1-py3-none-any.whl
| Download URL | git_rag_embedder-0.1.1-py3-none-any.whl |
|---|---|
| Size | 15.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f0cc67bb4602bfcdf96e7ed7da652de34c09824e73c6a70b1f0c716dd545c240
|
|
BLAKE2b-256 checksum How to use checksums |
fe215a46fc005b19e1c103fae9a92ba3a0791d3a423202d274096c2ca3bbb0ac
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 7, 2025.
Transparency logSecurity for git-rag-embedder 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for git_rag_embedder-0.1.1.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 7, 2025.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.