Download Sentence.py from jtesmer404/sentence_xform: direct link, hf CLI and curl.
- Browser
- Download file 427 Bytes
-
https://huggingface.co/jtesmer404/sentence_xform/resolve/main/Sentence.py
- Command line
-
hf download hf://jtesmer404/sentence_xform/Sentence.py
-
curl -L -o Sentence.py https://huggingface.co/jtesmer404/sentence_xform/resolve/main/Sentence.py
427 Bytes
| model_id = "sentence-transformers/all-MiniLM-L6-v2" | |
| hf_token = "get your token in http://hf.co/settings/tokens" | |
| import requests | |
| api_url = f"https://api-inference.huggingface.co/pipeline/feature-extraction/{model_id}" | |
| headers = {"Authorization": f"Bearer {hf_token}"} | |
| def query(texts): | |
| response = requests.post(api_url, headers=headers, json={"inputs": texts, "options":{"wait_for_model":True}}) | |
| return response.json() |