Create README.md
Browse files
README.md
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: gemma
|
| 3 |
+
library_name: transformers
|
| 4 |
+
pipeline_tag: text-generation
|
| 5 |
+
extra_gated_heading: Access Gemma on Hugging Face
|
| 6 |
+
extra_gated_prompt: >-
|
| 7 |
+
To access Gemma on Hugging Face, you’re required to review and agree to
|
| 8 |
+
Google’s usage license. To do this, please ensure you’re logged in to Hugging
|
| 9 |
+
Face and click below. Requests are processed immediately.
|
| 10 |
+
extra_gated_button_content: Acknowledge license
|
| 11 |
+
tags:
|
| 12 |
+
- conversational
|
| 13 |
+
base_model:
|
| 14 |
+
- google/gemma-3-270m-it
|
| 15 |
+
---
|
| 16 |
+
|
| 17 |
+
# gemma3-270m-it-sms-verification_code_extraction
|
| 18 |
+
#### SMS에서 인증번호를 추출 하는 gemma3 SFT 모델
|
| 19 |
+
- 모바일 내장을 위한 Quantization 모델입니다. 일반 모델은 아래 링크를 참조해주세요
|
| 20 |
+
- https://huggingface.co/sg2023/gemma3-270m-it-sms-verification_code_extraction
|
| 21 |
+
|
| 22 |
+
- Input / Output
|
| 23 |
+
- `"본인인증번호는 315611 입니다. 정확히 입력해주세요."` -> `315611`
|
| 24 |
+
- `"안녕하세요"` -> `0`
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
```python
|
| 28 |
+
from transformers import Gemma3ForCausalLM, AutoTokenizer
|
| 29 |
+
|
| 30 |
+
repo_id = "sg2023/gemma3-270m-it-sms-verification_code_extraction"
|
| 31 |
+
tokenizer = AutoTokenizer.from_pretrained(repo_id)
|
| 32 |
+
model = Gemma3ForCausalLM.from_pretrained(repo_id)
|
| 33 |
+
model.eval()
|
| 34 |
+
|
| 35 |
+
prompt = "본인인증번호는 315611 입니다. 정확히 입력해주세요."
|
| 36 |
+
request_template = [{"role": "user", "content": prompt}]
|
| 37 |
+
response_template = tokenizer.apply_chat_template(request_template, tokenize=False, add_generation_prompt=True)
|
| 38 |
+
inputs = tokenizer(response_template, return_tensors="pt").to(model.device)
|
| 39 |
+
input_ids = inputs["input_ids"][0] # Tensor shape: (seq_len,)
|
| 40 |
+
input_len = input_ids.shape[0]
|
| 41 |
+
|
| 42 |
+
outputs = model.generate(**inputs, max_new_tokens=64)[0]
|
| 43 |
+
outputs = outputs[input_len:]
|
| 44 |
+
outputs = tokenizer.decode(outputs, skip_special_tokens=True)
|
| 45 |
+
outputs = outputs.strip()
|
| 46 |
+
print(outputs) # 315611
|
| 47 |
+
```
|