Update README.md
Browse files
README.md
CHANGED
@@ -1,3 +1,107 @@
|
|
1 |
---
|
2 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
---
|
2 |
+
language:
|
3 |
+
- en
|
4 |
+
license: llama2
|
5 |
+
model_name: OpenHathi-7B-Hi-v0.1-Base-gptq
|
6 |
+
base_model: meta-llama/Llama-2-7b-chat-hf
|
7 |
+
inference: false
|
8 |
+
model_creator: SarvamAI
|
9 |
+
model_type: llama
|
10 |
+
pipeline_tag: text-generation
|
11 |
+
prompt_template: '[INST] <<SYS>>
|
12 |
+
|
13 |
+
You are a helpful, respectful and honest assistant. Always answer as helpfully as
|
14 |
+
possible, while being safe. Your answers should not include any harmful, unethical,
|
15 |
+
racist, sexist, toxic, dangerous, or illegal content. Please ensure that your responses
|
16 |
+
are socially unbiased and positive in nature. If a question does not make any sense,
|
17 |
+
or is not factually coherent, explain why instead of answering something not correct.
|
18 |
+
If you don''t know the answer to a question, please don''t share false information.
|
19 |
+
|
20 |
+
<</SYS>>
|
21 |
+
|
22 |
+
{prompt}[/INST]
|
23 |
+
|
24 |
+
'
|
25 |
+
quantized_by: cmeraki
|
26 |
---
|
27 |
+
|
28 |
+
# OpenHathi Base GPTQ
|
29 |
+
- Model creator: [Sarvam AI](https://huggingface.co/sarvamai)
|
30 |
+
- Original model: [sarvamai/OpenHathi-7B-Hi-v0.1-Base](https://huggingface.co/sarvamai/OpenHathi-7B-Hi-v0.1-Base/)
|
31 |
+
|
32 |
+
<!-- description start -->
|
33 |
+
## Description
|
34 |
+
|
35 |
+
This repo contains GPTQ model files for [Sarvam's OpenHathi](https://huggingface.co/sarvamai/OpenHathi-7B-Hi-v0.1-Base/).
|
36 |
+
|
37 |
+
Files are made using AutoGPTQ with following config.
|
38 |
+
```
|
39 |
+
quantization_config : {"bits": 4,
|
40 |
+
"group_size": 128,
|
41 |
+
"damp_percent": 0.1,
|
42 |
+
"desc_act": true,
|
43 |
+
|
44 |
+
}
|
45 |
+
```
|
46 |
+
|
47 |
+
We use a custom dataset which has both Hindi and English wiki articles. We truncate to max_length=1024 and model may not perform well beyond that context size.
|
48 |
+
|
49 |
+
<!-- description end -->
|
50 |
+
|
51 |
+
<!-- prompt-template start -->
|
52 |
+
## Prompt template
|
53 |
+
|
54 |
+
This is a base model not tuned for any instructions. Feel free to use any format. Alpaca/Vicuna works fine.
|
55 |
+
|
56 |
+
<!-- prompt-template end -->
|
57 |
+
|
58 |
+
## Oobagooba
|
59 |
+
Standard oobagooba works with exllama2 / autogptq loader
|
60 |
+
|
61 |
+
## Using in code
|
62 |
+
|
63 |
+
```python
|
64 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline
|
65 |
+
|
66 |
+
model_name_or_path = "cmeraki/OpenHathi-7B-Hi-v0.1-Base-gptq"
|
67 |
+
model = AutoModelForCausalLM.from_pretrained(model_name_or_path,
|
68 |
+
device_map="auto",
|
69 |
+
trust_remote_code=False,
|
70 |
+
revision="main")
|
71 |
+
|
72 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name_or_path, use_fast=True)
|
73 |
+
|
74 |
+
prompt = "do aur do"
|
75 |
+
prompt_template=f'''[INST] <<SYS>>
|
76 |
+
You are a helpful, respectful and honest assistant. Always answer as helpfully as possible, while being safe. Your answers should not include any harmful, unethical, racist, sexist, toxic, dangerous, or illegal content. Please ensure that your responses are socially unbiased and positive in nature. If a question does not make any sense, or is not factually coherent, explain why instead of answering something not correct. If you don't know the answer to a question, please don't share false information.
|
77 |
+
<</SYS>>
|
78 |
+
{prompt}[/INST]
|
79 |
+
|
80 |
+
'''
|
81 |
+
|
82 |
+
print("\n\n*** Generate:")
|
83 |
+
|
84 |
+
input_ids = tokenizer(prompt_template, return_tensors='pt').input_ids.cuda()
|
85 |
+
output = model.generate(inputs=input_ids, temperature=0.7, do_sample=True, top_p=0.95, top_k=40, max_new_tokens=512)
|
86 |
+
print(tokenizer.decode(output[0]))
|
87 |
+
|
88 |
+
# Inference can also be done using transformers' pipeline
|
89 |
+
|
90 |
+
print("*** Pipeline:")
|
91 |
+
pipe = pipeline(
|
92 |
+
"text-generation",
|
93 |
+
model=model,
|
94 |
+
tokenizer=tokenizer,
|
95 |
+
max_new_tokens=512,
|
96 |
+
do_sample=True,
|
97 |
+
temperature=0.7,
|
98 |
+
top_p=0.95,
|
99 |
+
top_k=40,
|
100 |
+
repetition_penalty=1.1
|
101 |
+
)
|
102 |
+
|
103 |
+
print(pipe(prompt_template)[0]['generated_text'])
|
104 |
+
```
|
105 |
+
<!-- README_GPTQ.md-use-from-python end -->
|
106 |
+
|
107 |
+
<!-- README_GPTQ.md-compatibility start -->
|