Instructions to use LugatitTurk/LugatitDistilBert with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use LugatitTurk/LugatitDistilBert with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-classification", model="LugatitTurk/LugatitDistilBert")# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForSequenceClassification tokenizer = AutoTokenizer.from_pretrained("LugatitTurk/LugatitDistilBert") model = AutoModelForSequenceClassification.from_pretrained("LugatitTurk/LugatitDistilBert", device_map="auto") - Notebooks
- Google Colab
- Kaggle
Update README.md
Browse files
README.md
CHANGED
|
@@ -32,4 +32,28 @@ tokenizer = AutoTokenizer.from_pretrained("LugatitTurk/LugatitDistilBert")
|
|
| 32 |
model = AutoModelForSequenceClassification.from_pretrained("LugatitTurk/LugatitDistilBert")
|
| 33 |
|
| 34 |
inputs = tokenizer("Hello, my dog is cute", return_tensors="pt")
|
| 35 |
-
outputs = model(**inputs)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 32 |
model = AutoModelForSequenceClassification.from_pretrained("LugatitTurk/LugatitDistilBert")
|
| 33 |
|
| 34 |
inputs = tokenizer("Hello, my dog is cute", return_tensors="pt")
|
| 35 |
+
outputs = model(**inputs)
|
| 36 |
+
|
| 37 |
+
# Example DataFrame
|
| 38 |
+
data = {
|
| 39 |
+
"text": [
|
| 40 |
+
"I love programming!",
|
| 41 |
+
"This is a terrible experience.",
|
| 42 |
+
"I'm feeling great today!"
|
| 43 |
+
]
|
| 44 |
+
}
|
| 45 |
+
|
| 46 |
+
df = pd.DataFrame(data)
|
| 47 |
+
|
| 48 |
+
# Function to classify text
|
| 49 |
+
def classify_text(text):
|
| 50 |
+
inputs = tokenizer(text, return_tensors="pt", truncation=True, padding=True)
|
| 51 |
+
outputs = model(**inputs)
|
| 52 |
+
probabilities = outputs.logits.softmax(dim=1)
|
| 53 |
+
predicted_class = probabilities.argmax().item()
|
| 54 |
+
return predicted_class
|
| 55 |
+
|
| 56 |
+
# Apply the classification function to the DataFrame
|
| 57 |
+
df["predicted_class"] = df["text"].apply(classify_text)
|
| 58 |
+
|
| 59 |
+
print(df)
|