Update README.md
Browse files
README.md
CHANGED
|
@@ -30,9 +30,64 @@ This model provides a new refresher in the field of emotion-aware dialogue syste
|
|
| 30 |
- **Paper:** xxxxxxxxxxxxxxxxxxx
|
| 31 |
|
| 32 |
## Uses
|
| 33 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 34 |
### Direct Use
|
| 35 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
|
| 37 |
|
| 38 |
## How to Get Started with the Model
|
|
|
|
| 30 |
- **Paper:** xxxxxxxxxxxxxxxxxxx
|
| 31 |
|
| 32 |
## Uses
|
| 33 |
+
This model is designed for multitask text-to-text generation in Indonesian, specifically trained for:
|
| 34 |
+
1. Dialogue Response Generation: Given a user utterance prefixed with dialog:, the model generates a relevant conversational response.
|
| 35 |
+
2. Emotion Classification: Given a text prefixed with emosi:, the model predicts the underlying emotion expressed in the text.
|
| 36 |
+
3. Context Understanding/Summarization (if applicable based on your training data): Given a text prefixed with konteks:, the model can perform tasks related to understanding or summarizing the provided context.
|
| 37 |
+
It's intended to be used directly via the transformers library in Python for applications requiring these specific capabilities in Indonesian.
|
| 38 |
### Direct Use
|
| 39 |
+
```
|
| 40 |
+
import torch
|
| 41 |
+
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
|
| 42 |
+
|
| 43 |
+
# Define the model repository ID
|
| 44 |
+
repo_id = "adhitia17/idmt"
|
| 45 |
+
|
| 46 |
+
# Load the tokenizer and model
|
| 47 |
+
print(f"Loading tokenizer and model from {repo_id}...")
|
| 48 |
+
tokenizer = AutoTokenizer.from_pretrained(repo_id)
|
| 49 |
+
model = AutoModelForSeq2SeqLM.from_pretrained(repo_id)
|
| 50 |
+
|
| 51 |
+
# Move model to GPU if available
|
| 52 |
+
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
| 53 |
+
model.to(device)
|
| 54 |
+
print(f"Model loaded to device: {device}")
|
| 55 |
+
|
| 56 |
+
def generate_response(input_text, task_prefix):
|
| 57 |
+
"""Generates a response from the model for a given task."""
|
| 58 |
+
full_input = f"{task_prefix}: {input_text}"
|
| 59 |
+
print(f"\nInput ({task_prefix}): {full_input}")
|
| 60 |
+
|
| 61 |
+
input_ids = tokenizer(full_input, return_tensors="pt").input_ids.to(device)
|
| 62 |
+
|
| 63 |
+
# Adjust generation parameters as needed
|
| 64 |
+
outputs = model.generate(
|
| 65 |
+
input_ids,
|
| 66 |
+
max_length=128, # Max length for the generated output
|
| 67 |
+
num_beams=5,
|
| 68 |
+
early_stopping=True
|
| 69 |
+
)
|
| 70 |
+
|
| 71 |
+
decoded_output = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
| 72 |
+
print(f"Output: {decoded_output}")
|
| 73 |
+
return decoded_output
|
| 74 |
+
|
| 75 |
+
# --- Example Usage ---
|
| 76 |
+
|
| 77 |
+
# 1. Dialogue Response Generation
|
| 78 |
+
user_dialogue = "halo, apa kabar?"
|
| 79 |
+
generate_response(user_dialogue, "dialog")
|
| 80 |
+
|
| 81 |
+
# 2. Emotion Classification
|
| 82 |
+
user_emotion_text = "saya sangat kecewa dengan hasilnya."
|
| 83 |
+
generate_response(user_emotion_text, "emosi")
|
| 84 |
+
|
| 85 |
+
# 3. Context Understanding (if applicable)
|
| 86 |
+
# user_context = "artikel ini membahas dampak perubahan iklim terhadap pertanian."
|
| 87 |
+
# generate_response(user_context, "konteks")
|
| 88 |
+
|
| 89 |
+
print("\nInference examples complete.")
|
| 90 |
+
```
|
| 91 |
|
| 92 |
|
| 93 |
## How to Get Started with the Model
|