Maninder Singh commited on
Commit
ac48d25
1 Parent(s): d17eb4a

Inference Code added

Browse files
Files changed (1) hide show
  1. README.md +45 -5
README.md CHANGED
@@ -50,10 +50,13 @@ Model is trained for 25 epochs on Azure for nearly 26000 Datapoints for above Me
50
 
51
  ## Below is the Training Result for 25 epochs.
52
  <ul>
53
- <li>Training Computer Configuration: GPU:1xNvidia Tesla T4,
54
- VRam: 16GB,
55
- Ram:112GB,
56
- Cores:6 Cores </li>
 
 
 
57
  <li>Training Time taken: exactly 7 hours for 25 epochs</li>
58
  <li>Training Hyper-parameters: </li>
59
  </ul>
@@ -64,4 +67,41 @@ Model is trained for 25 epochs on Azure for nearly 26000 Datapoints for above Me
64
 
65
 
66
 
67
- ![training detail.png](https://cdn-uploads.huggingface.co/production/uploads/645c859ad90782b1a6a3e957/Oi9TuJ8nEjtt6Z_W56myn.png)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
50
 
51
  ## Below is the Training Result for 25 epochs.
52
  <ul>
53
+ <li>Training Computer Configuration: <ul>
54
+ <li>GPU:1xNvidia Tesla T4, </li>
55
+ <li>VRam: 16GB,</li>
56
+ <li>Ram:112GB,</li>
57
+ <li>Cores:6 Cores </li>
58
+ </ul></li>
59
+
60
  <li>Training Time taken: exactly 7 hours for 25 epochs</li>
61
  <li>Training Hyper-parameters: </li>
62
  </ul>
 
67
 
68
 
69
 
70
+ ![training detail.png](https://cdn-uploads.huggingface.co/production/uploads/645c859ad90782b1a6a3e957/Oi9TuJ8nEjtt6Z_W56myn.png)
71
+
72
+ ## Inference Code
73
+
74
+ ```
75
+ import torch
76
+ from transformers import AutoTokenizer, AutoModelForSequenceClassification, TextClassificationPipeline
77
+ model_name = 'Maninder120996/programming-language-identification'
78
+ loaded_tokenizer = AutoTokenizer.from_pretrained(model_name)
79
+ loaded_model = AutoModelForSequenceClassification.from_pretrained(model_name)
80
+
81
+
82
+ device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
83
+ text = """
84
+ PROGRAM Triangle
85
+ IMPLICIT NONE
86
+ REAL :: a, b, c, Area
87
+ PRINT *, 'Welcome, please enter the&
88
+ &lengths of the 3 sides.'
89
+ READ *, a, b, c
90
+ PRINT *, 'Triangle''s area: ', Area(a,b,c)
91
+ END PROGRAM Triangle
92
+ FUNCTION Area(x,y,z)
93
+ IMPLICIT NONE
94
+ REAL :: Area ! function type
95
+ REAL, INTENT( IN ) :: x, y, z
96
+ REAL :: theta, height
97
+ theta = ACOS((x**2+y**2-z**2)/(2.0*x*y))
98
+ height = x*SIN(theta); Area = 0.5*y*height
99
+ END FUNCTION Area
100
+
101
+ """
102
+ inputs = loaded_tokenizer(text, return_tensors="pt",truncation=True)
103
+ with torch.no_grad():
104
+ logits = loaded_model(**inputs).logits
105
+ predicted_class_id = logits.argmax().item()
106
+ loaded_model.config.id2label[predicted_class_id]
107
+ ```