ricitos2001 commited on
Commit
0712107
·
verified ·
1 Parent(s): 86edd9e

Upload 2 files

Browse files
Files changed (2) hide show
  1. embedding.py +38 -0
  2. embeddings.csv +0 -0
embedding.py ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import pandas
3
+ import dotenv
4
+ import requests
5
+
6
+ dotenv.load_dotenv(dotenv.find_dotenv())
7
+ HF_TOKEN = os.environ['YOUR_TOKEN']
8
+
9
+ def query(api_url, headers, texts):
10
+ response = requests.post(api_url, headers=headers, json={"inputs": texts, "options":{"wait_for_model":True}})
11
+ return response.json()
12
+
13
+ def main():
14
+ model_id = "sentence-transformers/all-MiniLM-L6-v2"
15
+ api_url = f"https://api-inference.huggingface.co/pipeline/feature-extraction/{model_id}"
16
+ headers = {"Authorization": f"Bearer {HF_TOKEN}"}
17
+ texts = ["How do I get a replacement Medicare card?",
18
+ "What is the monthly premium for Medicare Part B?",
19
+ "How do I terminate my Medicare Part B (medical insurance)?",
20
+ "How do I sign up for Medicare?",
21
+ "Can I sign up for Medicare Part B if I am working and have health insurance through an employer?",
22
+ "How do I sign up for Medicare Part B if I already have Part A?",
23
+ "What are Medicare late enrollment penalties?",
24
+ "What is Medicare and who can get it?",
25
+ "How can I get help with my Medicare Part A and Part B premiums?",
26
+ "What are the different parts of Medicare?",
27
+ "Will my Medicare premiums be higher because of my higher income?",
28
+ "What is TRICARE ?",
29
+ "Should I sign up for Medicare Part B if I have Veterans' Benefits?"]
30
+
31
+ output = query(api_url, headers, texts)
32
+
33
+ embeddings = pandas.DataFrame(output)
34
+ embeddings.to_csv("embeddings.csv", index=False)
35
+
36
+ if __name__ == "__main__":
37
+ main()
38
+
embeddings.csv ADDED
The diff for this file is too large to render. See raw diff