rvv-karma commited on
Commit
7c13b3b
1 Parent(s): 8e92128

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +78 -0
README.md ADDED
@@ -0,0 +1,78 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language:
3
+ - en
4
+ tags:
5
+ - text-generation
6
+ - finetuned
7
+ widget:
8
+ - text: Is it raining in Hawaii?
9
+ example_title: Is it raining in Hawaii?
10
+ - text: Turn off music.
11
+ example_title: Turn off music.
12
+ - text: Is it snowing in New York?
13
+ example_title: Is it snowing in New York?
14
+ datasets:
15
+ - commonsense_qa
16
+ license: apache-2.0
17
+ pipeline_tag: text-generation
18
+ ---
19
+
20
+ # Commonsense-QA-Mistral-7B
21
+
22
+ This is a finetuned model of [mistralai/Mistral-7B-Instruct-v0.1](https://huggingface.co/mistralai/Mistral-7B-Instruct-v0.1)
23
+ with [commonsense_qa](https://huggingface.co/datasets/commonsense_qa) dataset.
24
+
25
+ The model is loaded in 4-bit and fine-tuned with LoRA.
26
+
27
+ ## Usage
28
+
29
+ ### Loading of model:
30
+ ```python
31
+ # Load model directly
32
+ from transformers import AutoTokenizer, AutoModelForCausalLM
33
+
34
+ model = AutoModelForCausalLM.from_pretrained(
35
+ "rvv-karma/Commonsense-QA-Mistral-7B",
36
+ low_cpu_mem_usage=True,
37
+ return_dict=True,
38
+ torch_dtype=torch.bfloat16,
39
+ device_map="auto",
40
+ )
41
+
42
+ tokenizer = AutoTokenizer.from_pretrained("rvv-karma/Commonsense-QA-Mistral-7B", trust_remote_code=True)
43
+ tokenizer.pad_token = tokenizer.eos_token
44
+ tokenizer.padding_side = "left"
45
+ ```
46
+
47
+ ### Sample:
48
+ ```python
49
+ pipe = pipeline(
50
+ task="text-generation",
51
+ model=model,
52
+ tokenizer=tokenizer,
53
+ return_full_text=False,
54
+ pad_token_id=tokenizer.pad_token_id,
55
+ eos_token_id=13,
56
+ max_new_tokens=8
57
+ )
58
+
59
+ prompt = """<s>
60
+ QUESTION:
61
+ The sensor would just the distance then set off an alarm, the installation expert explained it was called a what kind of sensor?
62
+
63
+ OPTIONS:
64
+ ["near", "closeness", "here", "proximity", "this"]
65
+
66
+ ANSWER:
67
+ """
68
+ result = pipe(prompt)
69
+ generated = result[0]['generated_text']
70
+ print(generated)
71
+
72
+ # Output: proximity
73
+ ```
74
+
75
+
76
+ ## Fine-tuning script
77
+
78
+ [Kaggle Notebook](https://www.kaggle.com/rvkarma/commonsense-qa-mistral-7b)