Spaces:
Running
Running
Merge pull request #20 from AutoLLM/use-3.5-turbo-16k
Browse files- README.md +1 -1
- src/action.py +1 -1
- src/relevancy.py +7 -8
README.md
CHANGED
@@ -28,7 +28,7 @@ Staying up to date on [arXiv](https://arxiv.org) papers can take a considerable
|
|
28 |
This repository offers a method to curate a daily digest, sorted by relevance, using large language models. These models are conditioned based on your personal research interests, which are described in natural language.
|
29 |
|
30 |
* You modify the configuration file `config.yaml` with an arXiv Subject, some set of Categories, and a natural language statement about the type of papers you are interested in.
|
31 |
-
* The code pulls all the abstracts for papers in those categories and ranks how relevant they are to your interest on a scale of 1-10 using `gpt-3.5-turbo`.
|
32 |
* The code then emits an HTML digest listing all the relevant papers, and optionally emails it to you using [SendGrid](https://sendgrid.com). You will need to have a SendGrid account with an API key for this functionality to work.
|
33 |
|
34 |
### Testing it out with Hugging Face:
|
|
|
28 |
This repository offers a method to curate a daily digest, sorted by relevance, using large language models. These models are conditioned based on your personal research interests, which are described in natural language.
|
29 |
|
30 |
* You modify the configuration file `config.yaml` with an arXiv Subject, some set of Categories, and a natural language statement about the type of papers you are interested in.
|
31 |
+
* The code pulls all the abstracts for papers in those categories and ranks how relevant they are to your interest on a scale of 1-10 using `gpt-3.5-turbo-16k`.
|
32 |
* The code then emits an HTML digest listing all the relevant papers, and optionally emails it to you using [SendGrid](https://sendgrid.com). You will need to have a SendGrid account with an API key for this functionality to work.
|
33 |
|
34 |
### Testing it out with Hugging Face:
|
src/action.py
CHANGED
@@ -92,7 +92,7 @@ def generate_body(topic, categories, interest, threshold):
|
|
92 |
papers,
|
93 |
query={"interest": interest},
|
94 |
threshold_score=threshold,
|
95 |
-
num_paper_in_prompt=
|
96 |
body = "<br><br>".join(
|
97 |
[f'Title: <a href="{paper["main_page"]}">{paper["title"]}</a><br>Authors: {paper["authors"]}<br>Score: {paper["Relevancy score"]}<br>Reason: {paper["Reasons for match"]}'
|
98 |
for paper in relevancy])
|
|
|
92 |
papers,
|
93 |
query={"interest": interest},
|
94 |
threshold_score=threshold,
|
95 |
+
num_paper_in_prompt=16)
|
96 |
body = "<br><br>".join(
|
97 |
[f'Title: <a href="{paper["main_page"]}">{paper["title"]}</a><br>Authors: {paper["authors"]}<br>Score: {paper["Relevancy score"]}<br>Reason: {paper["Reasons for match"]}'
|
98 |
for paper in relevancy])
|
src/relevancy.py
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
run:
|
3 |
python -m relevancy run_all_day_paper \
|
4 |
--output_dir ./data \
|
5 |
-
--model_name="gpt-3.5-turbo" \
|
6 |
"""
|
7 |
import time
|
8 |
import json
|
@@ -53,7 +53,7 @@ def post_process_chat_gpt_response(paper_data, response, threshold_score=8):
|
|
53 |
scores = []
|
54 |
for item in score_items:
|
55 |
temp = item["Relevancy score"]
|
56 |
-
if "/" in temp:
|
57 |
scores.append(int(temp.split("/")[0]))
|
58 |
else:
|
59 |
scores.append(int(temp))
|
@@ -72,7 +72,7 @@ def post_process_chat_gpt_response(paper_data, response, threshold_score=8):
|
|
72 |
output_str += "Link: " + paper_data[idx]["main_page"] + "\n"
|
73 |
for key, value in inst.items():
|
74 |
paper_data[idx][key] = value
|
75 |
-
output_str += key + ": " + value + "\n"
|
76 |
paper_data[idx]['summarized_text'] = output_str
|
77 |
selected_data.append(paper_data[idx])
|
78 |
return selected_data, hallucination
|
@@ -90,7 +90,7 @@ def process_subject_fields(subjects):
|
|
90 |
def generate_relevance_score(
|
91 |
all_papers,
|
92 |
query,
|
93 |
-
model_name="gpt-3.5-turbo",
|
94 |
threshold_score=8,
|
95 |
num_paper_in_prompt=4,
|
96 |
temperature=0.4,
|
@@ -108,7 +108,7 @@ def generate_relevance_score(
|
|
108 |
decoding_args = utils.OpenAIDecodingArguments(
|
109 |
temperature=temperature,
|
110 |
n=1,
|
111 |
-
max_tokens=
|
112 |
top_p=top_p,
|
113 |
)
|
114 |
request_start = time.time()
|
@@ -118,7 +118,6 @@ def generate_relevance_score(
|
|
118 |
batch_size=1,
|
119 |
decoding_args=decoding_args,
|
120 |
logit_bias={"100257": -100}, # prevent the <|endoftext|> from being generated
|
121 |
-
# "100265":-100, "100276":-100 for <|im_end|> and <endofprompt> token
|
122 |
)
|
123 |
print ("response", response['message']['content'])
|
124 |
request_duration = time.time() - request_start
|
@@ -132,7 +131,7 @@ def generate_relevance_score(
|
|
132 |
print(f"Post-processing took {time.time() - process_start:.2f}s")
|
133 |
|
134 |
if sorting:
|
135 |
-
ans_data = sorted(ans_data, key=lambda x: x["Relevancy score"], reverse=True)
|
136 |
|
137 |
return ans_data, hallucination
|
138 |
|
@@ -140,7 +139,7 @@ def run_all_day_paper(
|
|
140 |
query={"interest":"", "subjects":["Computation and Language", "Artificial Intelligence"]},
|
141 |
date=None,
|
142 |
data_dir="../data",
|
143 |
-
model_name="gpt-3.5-turbo",
|
144 |
threshold_score=8,
|
145 |
num_paper_in_prompt=8,
|
146 |
temperature=0.4,
|
|
|
2 |
run:
|
3 |
python -m relevancy run_all_day_paper \
|
4 |
--output_dir ./data \
|
5 |
+
--model_name="gpt-3.5-turbo-16k" \
|
6 |
"""
|
7 |
import time
|
8 |
import json
|
|
|
53 |
scores = []
|
54 |
for item in score_items:
|
55 |
temp = item["Relevancy score"]
|
56 |
+
if isinstance(temp, str) and "/" in temp:
|
57 |
scores.append(int(temp.split("/")[0]))
|
58 |
else:
|
59 |
scores.append(int(temp))
|
|
|
72 |
output_str += "Link: " + paper_data[idx]["main_page"] + "\n"
|
73 |
for key, value in inst.items():
|
74 |
paper_data[idx][key] = value
|
75 |
+
output_str += str(key) + ": " + str(value) + "\n"
|
76 |
paper_data[idx]['summarized_text'] = output_str
|
77 |
selected_data.append(paper_data[idx])
|
78 |
return selected_data, hallucination
|
|
|
90 |
def generate_relevance_score(
|
91 |
all_papers,
|
92 |
query,
|
93 |
+
model_name="gpt-3.5-turbo-16k",
|
94 |
threshold_score=8,
|
95 |
num_paper_in_prompt=4,
|
96 |
temperature=0.4,
|
|
|
108 |
decoding_args = utils.OpenAIDecodingArguments(
|
109 |
temperature=temperature,
|
110 |
n=1,
|
111 |
+
max_tokens=128*num_paper_in_prompt, # The response for each paper should be less than 128 tokens.
|
112 |
top_p=top_p,
|
113 |
)
|
114 |
request_start = time.time()
|
|
|
118 |
batch_size=1,
|
119 |
decoding_args=decoding_args,
|
120 |
logit_bias={"100257": -100}, # prevent the <|endoftext|> from being generated
|
|
|
121 |
)
|
122 |
print ("response", response['message']['content'])
|
123 |
request_duration = time.time() - request_start
|
|
|
131 |
print(f"Post-processing took {time.time() - process_start:.2f}s")
|
132 |
|
133 |
if sorting:
|
134 |
+
ans_data = sorted(ans_data, key=lambda x: int(x["Relevancy score"]), reverse=True)
|
135 |
|
136 |
return ans_data, hallucination
|
137 |
|
|
|
139 |
query={"interest":"", "subjects":["Computation and Language", "Artificial Intelligence"]},
|
140 |
date=None,
|
141 |
data_dir="../data",
|
142 |
+
model_name="gpt-3.5-turbo-16k",
|
143 |
threshold_score=8,
|
144 |
num_paper_in_prompt=8,
|
145 |
temperature=0.4,
|