This release is a pre-release and may not be stable for production use.
Swarmauri Parser Bert Embedding
swarmauri_parser_bertembedding is the Swarmauri embedding parser for turning
text into dense vector representations with Hugging Face BERT models. It
returns Swarmauri Document objects whose content keeps the original text
and whose metadata stores the generated embedding vector.
Why Use Swarmauri Parser Bert Embedding
- Generate dense semantic vectors inside a Swarmauri parser-style workflow.
- Keep original text and embedding output together in a single
Documentobject. - Swap BERT model names when you need a different encoder surface.
- Feed embeddings into retrieval, clustering, semantic search, reranking, or downstream vector store pipelines.
FAQ
What does this parser output?
SwarmauriDocumentobjects containing the original text and an averaged BERT embedding stored inmetadata["embedding"].
What model does it use by default?
bert-base-uncased.
Can it parse a batch of strings?
Yes. The current implementation accepts a single string or a list of strings.
Does it download model weights?
Yes. On first use, Hugging Face model and tokenizer assets are downloaded if they are not already cached locally.
Features
- Dense embedding generation using
BertTokenizerandBertModel. - Supports single-string and batch-text parsing.
- Stores the original text alongside the embedding vector in each document.
- Uses inference mode with
torch.no_grad()and mean token pooling. - Supports Python 3.10, 3.11, 3.12, 3.13, and 3.14.
Installation
uv add swarmauri_parser_bertembedding
pip install swarmauri_parser_bertembedding
Notes:
- First-run model downloads come from Hugging Face.
- Install a CUDA-enabled PyTorch build separately if GPU execution is required.
Usage
from swarmauri_parser_bertembedding import BERTEmbeddingParser
parser = BERTEmbeddingParser(parser_model_name="bert-base-uncased")
documents = parser.parse(
[
"Swarmauri agents cooperate over shared memory.",
"Dense embeddings power semantic search.",
]
)
for document in documents:
embedding = document.metadata["embedding"]
print(document.content)
print(len(embedding), embedding[:5])
Examples
Embed a single sentence
from swarmauri_parser_bertembedding import BERTEmbeddingParser
parser = BERTEmbeddingParser()
documents = parser.parse("Composable intelligence infrastructure")
print(documents[0].id)
print(documents[0].metadata["source"])
print(documents[0].metadata["embedding"].shape)
Embed a batch for downstream storage
from swarmauri_parser_bertembedding import BERTEmbeddingParser
texts = [
"Customer support workflows need retrieval.",
"Embeddings support semantic matching.",
"Vector stores preserve nearest-neighbor search state.",
]
parser = BERTEmbeddingParser()
documents = parser.parse(texts)
for document in documents:
vector = document.metadata["embedding"]
print(document.id, len(vector))
Use an alternate BERT model name
from swarmauri_parser_bertembedding import BERTEmbeddingParser
parser = BERTEmbeddingParser(parser_model_name="bert-base-multilingual-cased")
docs = parser.parse("Bonjour tout le monde")
print(docs[0].metadata["embedding"][:5])
Related Packages
- swarmauri_embedding_mlm
- swarmauri_vectorstore_mlm
- swarmauri_vectorstore_qdrant
- swarmauri_vectorstore_pinecone
Swarmauri Foundations
More Documentation
- Hugging Face Transformers BERT docs
- Transformers AutoTokenizer and tokenization docs
- PyTorch documentation
Best Practices
- Chunk very long texts before parsing so they stay within the BERT token limit.
- Cache Hugging Face assets in CI and deployment environments to avoid repeated model downloads.
- Use a model variant aligned to your language and domain.
- Persist vectors into a Swarmauri vector store if you plan to search or reuse them beyond a single process.
License
This project is licensed under the Apache-2.0 License.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file swarmauri_parser_bertembedding-0.11.0.dev1.tar.gz.
File metadata
- Download URL: swarmauri_parser_bertembedding-0.11.0.dev1.tar.gz
- Upload date:
- Size: 8.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0f5c841c5c130a9ca2ad202eeca70128153d77790cc44ed86adbae5a1e804beb
|
|
| MD5 |
fe534919f13e08d5400bcec4b320fb6c
|
|
| BLAKE2b-256 |
a36264db3e72031f702f83094129122cfef4294ad2b7067b9aca9531407ac048
|
File details
Details for the file swarmauri_parser_bertembedding-0.11.0.dev1-py3-none-any.whl.
File metadata
- Download URL: swarmauri_parser_bertembedding-0.11.0.dev1-py3-none-any.whl
- Upload date:
- Size: 9.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e52e7029df11444581a79bc69b300c06f8e573b74635dfef0ba4a6837849dab7
|
|
| MD5 |
3ce66ada79e272f3656201da63e41ebd
|
|
| BLAKE2b-256 |
a0a3bd1f358bc6c34dc589c44ec572901ca086eb9a25beb7af221f57ccd92872
|