msaad02 commited on
Commit
1cc9ab0
1 Parent(s): 867de23

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +74 -0
README.md CHANGED
@@ -12,3 +12,77 @@ This model is part of my thesis to make a question-answering bot for SUNY Brockp
12
 
13
  For more information, see my [github repo](https://github.com/msaad02/honors-thesis) for the project.
14
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
 
13
  For more information, see my [github repo](https://github.com/msaad02/honors-thesis) for the project.
14
 
15
+ ## Examples
16
+
17
+ >Are SAT scores required?
18
+ >>SAT scores are not required for admission, but test scores are used as part of Brockport's holistic review process to make admissions decisions.
19
+
20
+ >Who can I contact for help with financial aid?
21
+ >>You can contact the financial aid office at SUNY Brockport for assistance with financial aid. They are available to answer any questions and help you navigate the financial aid process.
22
+
23
+
24
+ ## Prompting
25
+
26
+ This prompting style is what was used for finetuning:
27
+
28
+ >Below is an inquiry related to SUNY Brockport - from academics, admissions, and faculty support to student life. Prioritize accuracy and brevity.
29
+ >
30
+ >\### Instruction:\
31
+ >{question}
32
+ >
33
+ >\### Response:\
34
+ >{response}
35
+
36
+ ## Usage
37
+
38
+ To run this model, I suggest using the following code to build a pipeline, which implements the correct prompt formatting
39
+
40
+ ```python
41
+ import torch
42
+ from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig
43
+ import textwrap
44
+
45
+ bnb_config = BitsAndBytesConfig(
46
+ load_in_4bit=True,
47
+ bnb_4bit_quant_type="nf4",
48
+ bnb_4bit_compute_dtype=torch.bfloat16,
49
+ )
50
+
51
+ model = AutoModelForCausalLM.from_pretrained(
52
+ "msaad02/llama2_7b_brockport_gpt",
53
+ quantization_config=bnb_config,
54
+ device_map={"": 0},
55
+ trust_remote_code=True
56
+ )
57
+
58
+ tokenizer = AutoTokenizer.from_pretrained("msaad02/llama2_7b_brockport_gpt")
59
+
60
+ # Use a pipeline as a high-level helper
61
+ from transformers import pipeline
62
+
63
+ pipe = pipeline(
64
+ task="text-generation",
65
+ model=model,
66
+ tokenizer=tokenizer
67
+ )
68
+
69
+ def qa(text: str, full = False):
70
+ # textwrap.dedent gets rid of indenting at the start of each newline
71
+ text = textwrap.dedent(f"""\
72
+ Below is an inquiry related to SUNY Brockport - from academics, admissions, and faculty support to student life. Prioritize accuracy and brevity.
73
+
74
+ ### Instruction:
75
+ {text}
76
+
77
+ ### Response:
78
+ """)
79
+
80
+ response = pipe(text, max_length=100, do_sample=True, top_k=50, top_p=0.95, temperature=1.0)
81
+ response = response[0]['generated_text']
82
+ response = response.split("### Response:\n")[1] if not full else response
83
+
84
+ return response
85
+
86
+ print(qa("How do I apply?", full = True))
87
+ ```
88
+