Download examples/quickstart.py from changh95/all-MiniLM-L6-v2: direct link, hf CLI and curl.
- Browser
- Download file 710 Bytes
-
https://huggingface.co/changh95/all-MiniLM-L6-v2/resolve/main/examples/quickstart.py
- Command line
-
hf download hf://changh95/all-MiniLM-L6-v2/examples/quickstart.py
-
curl -L -o quickstart.py https://huggingface.co/changh95/all-MiniLM-L6-v2/resolve/main/examples/quickstart.py
710 Bytes
| # SPDX-License-Identifier: Apache-2.0 | |
| """Quickstart: semantic search with all-MiniLM-L6-v2 on a Tenstorrent p150 (python examples/quickstart.py).""" | |
| from tt_minilm.api import MiniLM | |
| docs = ["Paris is the capital and most populous city of France.", | |
| "Photovoltaic cells convert sunlight directly into electricity.", | |
| "Build mileage gradually and include one long run per week before a marathon."] | |
| queries = ["What is the capital of France?", "how do solar panels work", "marathon training tips"] | |
| with MiniLM.from_pretrained() as m: | |
| d = m.encode(docs) | |
| q = m.encode(queries) | |
| for i, s in enumerate(q @ d.T): | |
| print(f"{queries[i]!r} -> {docs[int(s.argmax())]!r} ({s.max():.3f})") | |