forked from ainize-team/klue-re-workspace
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
34 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# Tutorial for KLUE Relation Extraction. | ||
Fine-tuning klue/bert-base using KLUE RE dataset. | ||
- <a href="https://klue-benchmark.com/">KLUE Benchmark Official Webpage</a> | ||
- <a href="https://github.com/KLUE-benchmark/KLUE">KLUE Official Github</a> | ||
- <a href="https://huggingface.co/ainize/klue-bert-base-re">Model on Huggingface</a> | ||
- Run KLUE RE on free GPU : <a href="https://ainize.ai/workspace/create?imageId=hnj95592adzr02xPTqss&git=https://github.com/ainize-team/klue-re-workspace">Ainize Workspace</a> | ||
|
||
# Usage | ||
- <a href="https://github.com/KLUE-benchmark/KLUE/blob/main/klue_benchmark/klue-re-v1/relation_list.json">KLUE Relation List</a> | ||
<pre><code> | ||
from transformers import AutoTokenizer, AutoModelForSequenceClassification | ||
|
||
tokenizer = AutoTokenizer.from_pretrained("ainize/klue-bert-base-re") | ||
model = AutoModelForSequenceClassification.from_pretrained("ainize/klue-bert-base-re") | ||
|
||
# Add "<subj>", "</subj>" to both ends of the subject object and "<obj>", "</obj>" to both ends of the object object. | ||
sentence = "<subj>손흥민</subj>은 <obj>대한민국</obj>에서 태어났다." | ||
|
||
encodings = tokenizer(sentence, | ||
max_length=128, | ||
truncation=True, | ||
padding="max_length", | ||
return_tensors="pt") | ||
|
||
outputs = model(**encodings) | ||
|
||
logits = outputs['logits'] | ||
|
||
preds = torch.argmax(logits, dim=1) | ||
</code></pre> | ||
|
||
# About us | ||
- <a href="https://ainize.ai/teachable-nlp">Teachable NLP</a> - Train NLP models with your own text without writing any code | ||
- <a href="https://ainize.ai/">Ainize</a> - Deploy ML project using free gpu |