Update README.md
Browse files
README.md
CHANGED
|
@@ -48,10 +48,25 @@ model = AutoModelForCausalLM.from_pretrained(
|
|
| 48 |
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
| 49 |
|
| 50 |
# Define input query
|
| 51 |
-
prompt = "
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 52 |
messages = [
|
| 53 |
-
{
|
| 54 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 55 |
]
|
| 56 |
|
| 57 |
# Apply chat template
|
|
@@ -60,7 +75,12 @@ text = tokenizer.apply_chat_template(
|
|
| 60 |
tokenize=False,
|
| 61 |
add_generation_prompt=True
|
| 62 |
)
|
| 63 |
-
model_inputs = tokenizer(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 64 |
|
| 65 |
# Generate rewritten query
|
| 66 |
generated_ids = model.generate(
|
|
|
|
| 48 |
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
| 49 |
|
| 50 |
# Define input query
|
| 51 |
+
prompt = "Claim in article about why insects are attracted to light\nIn this article they are addressing the reason insects are attracted to light when they say\nHeat radiation as an attractive component is refuted by the effect of LED lighting, which supplies negligible infrared radiation yet still entraps vast numbers of insects.\nI don't see why attraction to LEDs shows they're not seeking heat. Could they for example be evolutionarily programmed to associate light with heat? So that even though they don't encounter heat near/on the LEDs they still \"expect\" to?"
|
| 52 |
+
|
| 53 |
+
QUERY_WRITER_PROMPT = (
|
| 54 |
+
"For the input query, formulating a concise search query for dense retrieval by distilling the core intent from a complex user prompt and ignoring LLM instructions."
|
| 55 |
+
"The response should be less than 200 words"
|
| 56 |
+
)
|
| 57 |
messages = [
|
| 58 |
+
{
|
| 59 |
+
"role": "system",
|
| 60 |
+
"content": "You are Qwen, created by Alibaba Cloud. You are a helpful assistant.",
|
| 61 |
+
},
|
| 62 |
+
{
|
| 63 |
+
"role": "user",
|
| 64 |
+
"content": (
|
| 65 |
+
f"{QUERY_WRITER_PROMPT}\n\n"
|
| 66 |
+
f"**Input Query:**\n{prompt}\n"
|
| 67 |
+
f"**Your Output:**\n"
|
| 68 |
+
),
|
| 69 |
+
},
|
| 70 |
]
|
| 71 |
|
| 72 |
# Apply chat template
|
|
|
|
| 75 |
tokenize=False,
|
| 76 |
add_generation_prompt=True
|
| 77 |
)
|
| 78 |
+
model_inputs = tokenizer(
|
| 79 |
+
[text],
|
| 80 |
+
truncation=True,
|
| 81 |
+
max_length=8192,
|
| 82 |
+
return_tensors="pt"
|
| 83 |
+
).to(model.device)
|
| 84 |
|
| 85 |
# Generate rewritten query
|
| 86 |
generated_ids = model.generate(
|