Safetensors
Indonesian
t5
idmt
adhitia17 commited on
Commit
905e391
·
verified ·
1 Parent(s): c0f6e23

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +1 -18
README.md CHANGED
@@ -40,15 +40,12 @@ It's intended to be used directly via the transformers library in Python for app
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}")
@@ -60,10 +57,9 @@ def generate_response(input_text, task_prefix):
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
  )
@@ -72,19 +68,6 @@ def generate_response(input_text, task_prefix):
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
  ```
 
40
  import torch
41
  from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
42
 
 
43
  repo_id = "adhitia17/idmt"
44
 
 
45
  print(f"Loading tokenizer and model from {repo_id}...")
46
  tokenizer = AutoTokenizer.from_pretrained(repo_id)
47
  model = AutoModelForSeq2SeqLM.from_pretrained(repo_id)
48
 
 
49
  device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
50
  model.to(device)
51
  print(f"Model loaded to device: {device}")
 
57
 
58
  input_ids = tokenizer(full_input, return_tensors="pt").input_ids.to(device)
59
 
 
60
  outputs = model.generate(
61
  input_ids,
62
+ max_length=256,
63
  num_beams=5,
64
  early_stopping=True
65
  )
 
68
  print(f"Output: {decoded_output}")
69
  return decoded_output
70
 
 
 
 
 
 
 
 
 
 
 
 
 
 
71
 
72
  print("\nInference examples complete.")
73
  ```