Skip to main content

LangChain embeddings that run on the Apple Neural Engine, via ANEForge (no CoreML).

Project description

langchain-aneforge

LangChain embeddings that run on the Apple Neural Engine, via ANEForge. The encoder runs on the ANE with no CoreML, matching the fp32 reference to cosine ~1.0 at a fraction of the GPU's energy.

pip install langchain-aneforge

Apple Silicon macOS only (ANEForge reaches the engine through a built dispatch shim; see the ANEForge install notes).

Use

from langchain_aneforge import ANEEmbeddings

emb = ANEEmbeddings(model="sentence-transformers/all-MiniLM-L6-v2")
vec = emb.embed_query("the Apple Neural Engine runs networks at low power")
docs = emb.embed_documents(["one passage", "another passage"])

ANEEmbeddings is a standard langchain_core.embeddings.Embeddings, so it drops into any LangChain retriever or vector store:

from langchain_community.vectorstores import FAISS

store = FAISS.from_texts(["...", "..."], ANEEmbeddings())
hits = store.similarity_search("query", k=3)

model is any BERT-family sentence encoder on the Hugging Face hub. Its pooling mode and normalize flag are read from the model's own sentence-transformers config, so mean-pooled (MiniLM, E5) and cls-pooled (BGE, GTE) models both produce correct vectors. Pass int8=True to stream int8 weights (half the size, cosine ~0.9999).

License

MIT. Not affiliated with or endorsed by Apple or LangChain.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

langchain_aneforge-0.1.0.tar.gz (3.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

langchain_aneforge-0.1.0-py3-none-any.whl (4.0 kB view details)

Uploaded Python 3

File details

Details for the file langchain_aneforge-0.1.0.tar.gz.

File metadata

  • Download URL: langchain_aneforge-0.1.0.tar.gz
  • Upload date:
  • Size: 3.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for langchain_aneforge-0.1.0.tar.gz
Algorithm Hash digest
SHA256 011bfbfc6265e5b7eca2690f61dd87f9da3c704950d7e077cffec6dba5f11bfd
MD5 34d35daaa671d51d21176134c3df600a
BLAKE2b-256 50f8e51817890745862db1177bde38677c803bf25566267fe782807282ff0c3b

See more details on using hashes here.

Provenance

The following attestation bundles were made for langchain_aneforge-0.1.0.tar.gz:

Publisher: publish.yml on sbryngelson/langchain-aneforge

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file langchain_aneforge-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for langchain_aneforge-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e55d1c442a111296b4bac6fe414555b5955625d3579d7980236c4928f31e0e88
MD5 4b696e5b226cce1810ed891407ed3f0b
BLAKE2b-256 596fe5b45847f60ad69460fc1644c9a129285c45d5786d48c4e54b95b0910fbd

See more details on using hashes here.

Provenance

The following attestation bundles were made for langchain_aneforge-0.1.0-py3-none-any.whl:

Publisher: publish.yml on sbryngelson/langchain-aneforge

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page