kirankunapuli commited on
Commit
ff3d2de
1 Parent(s): f994de4

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +17 -3
README.md CHANGED
@@ -17,13 +17,15 @@ datasets:
17
  pipeline_tag: text-generation
18
  ---
19
 
20
- # Gemma-2B-Hinglish-LORA-v1.0 model
 
21
 
22
  - **Developed by:** [Kiran Kunapuli](https://www.linkedin.com/in/kirankunapuli/)
23
  - **License:** apache-2.0
24
  - **Finetuned from model :** unsloth/gemma-2b-bnb-4bit
25
  - **Model usage:** Use the below code in Python
26
  ```python
 
27
  import torch
28
  from transformers import AutoTokenizer, AutoModelForCausalLM
29
 
@@ -55,7 +57,11 @@ pipeline_tag: text-generation
55
  ], return_tensors = "pt").to(device)
56
 
57
  outputs = model.generate(**inputs, max_new_tokens = 64, use_cache = True)
58
- print(tokenizer.batch_decode(outputs))
 
 
 
 
59
 
60
  # Example 2
61
  inputs = tokenizer(
@@ -68,7 +74,15 @@ pipeline_tag: text-generation
68
  ], return_tensors = "pt").to(device)
69
 
70
  outputs = model.generate(**inputs, max_new_tokens = 64, use_cache = True)
71
- print(tokenizer.batch_decode(outputs))
 
 
 
 
 
 
 
 
72
  ```
73
  - **Model config:**
74
  ```python
 
17
  pipeline_tag: text-generation
18
  ---
19
 
20
+ # 🔥 Gemma-2B-Hinglish-LORA-v1.0 model
21
+ ### 🚀 Visit this HF Space to try out this model's inference: https://huggingface.co/spaces/kirankunapuli/Gemma-2B-Hinglish-Model-Inference-v1.0
22
 
23
  - **Developed by:** [Kiran Kunapuli](https://www.linkedin.com/in/kirankunapuli/)
24
  - **License:** apache-2.0
25
  - **Finetuned from model :** unsloth/gemma-2b-bnb-4bit
26
  - **Model usage:** Use the below code in Python
27
  ```python
28
+ import re
29
  import torch
30
  from transformers import AutoTokenizer, AutoModelForCausalLM
31
 
 
57
  ], return_tensors = "pt").to(device)
58
 
59
  outputs = model.generate(**inputs, max_new_tokens = 64, use_cache = True)
60
+ output = tokenizer.batch_decode(outputs)[0]
61
+ response_start = output.find("### Response:") + len("### Response:")
62
+ response_end = output.find("<eos>", response_start)
63
+ response = output[response_start:response_end].strip()
64
+ print(response)
65
 
66
  # Example 2
67
  inputs = tokenizer(
 
74
  ], return_tensors = "pt").to(device)
75
 
76
  outputs = model.generate(**inputs, max_new_tokens = 64, use_cache = True)
77
+ output = tokenizer.batch_decode(outputs)[0]
78
+ response_pattern = re.compile(r'### Response:\n(.*?)<eos>', re.DOTALL)
79
+ response_match = response_pattern.search(output)
80
+
81
+ if response_match:
82
+ response = response_match.group(1).strip()
83
+ return response
84
+ else:
85
+ return "Response not found"
86
  ```
87
  - **Model config:**
88
  ```python