Views
No views yet

1import torch
2from transformers import AutoTokenizer, AutoModelForCausalLM, pipeline,set_seed
3
4model_name = "RedHenLabs/news-reporter-3b"
5
6tokenizer = AutoTokenizer.from_pretrained(model_name,trust_remote_code=True)
7model = AutoModelForCausalLM.from_pretrained(model_name, trust_remote_code=True, torch_dtype="auto", device_map="cuda")
8
9pipe = pipeline("text-generation", model=model, tokenizer=tokenizer)
10
11def test_inference(prompt):
12 prefix = "Generate a concise and accurate news summary based on the following question.\n Input:"
13 prompt = pipe.tokenizer.apply_chat_template([{"role": "user", "content": prefix+prompt}], tokenize=False, add_generation_prompt=True)
14 outputs = pipe(prompt, max_new_tokens=512, do_sample=True, num_beams=1, temperature=0.1, top_k=50, top_p=0.95,
15 max_time= 180)
16 return outputs[0]['generated_text'][len(prompt):].strip()
17
18res = test_inference(" What is the status of the evacuations and the condition of those injured?")
19print(res)| (0 Shot) | News-reporter-3b | Phi-3-mini-4k | Gemma-7b-it | Llama-2-7B | Mistral-7B-Instruct-v0.2 |
|---|---|---|---|---|---|
| MMLU | 69.49 | 69.90 | 64.3 | 45.3 | 59.02 |
| ARC_C | 56.40 | 56.14 | 53.2 | 45.9 | 55.89 |
| Winogrande | 74.19 | 73.24 | 68.03 | 69.5 | 73.72 |
| Truthfulqa | 50.43 | 66.46 | 44.18 | 57.4 | 53.00 |
@misc {lucifertrj,
author = { {Tarun Jain} },
title = { News Reporter 3B by Red Hen Lab part of Google Summer of Code 2024},
year = 2024,
url = { https://huggingface.co/RedHenLabs/news-reporter-3b },
publisher = { Hugging Face }
}