Views
No views yet
PersonLawPublicationGovernmentCorporationOtherProjectMoneyDateLocationCourt1from transformers import pipeline
2
3# Load the pipeline
4model = pipeline("ner", model="farnazzeidi/ner-legalturk-bert-model", aggregation_strategy='simple')
5
6# Input text
7text = "Burada, Tebligat Kanunu ile VUK düzenlemesi ayrımına dikkat etmek gerekir."
8
9# Get predictions
10predictions = model(text)
11print(predictions)1from transformers import AutoTokenizer, AutoModelForTokenClassification
2import torch
3
4# Load model and tokenizer
5
6tokenizer = AutoTokenizer.from_pretrained("farnazzeidi/ner-legalturk-bert-model")
7model = AutoModelForTokenClassification.from_pretrained("farnazzeidi/ner-legalturk-bert-model")
8
9text = "Burada, Tebligat Kanunu ile VUK düzenlemesi ayrımına dikkat etmek gerekir."
10inputs = tokenizer(text, return_tensors="pt")
11outputs = model(**inputs)
12
13# Process logits and map predictions to labels
14predictions = [
15 (token, model.config.id2label[label.item()])
16 for token, label in zip(
17 tokenizer.convert_ids_to_tokens(inputs["input_ids"][0]),
18 torch.argmax(torch.softmax(outputs.logits, dim=-1), dim=-1)[0]
19 )
20 if token not in tokenizer.all_special_tokens
21]
22
23print(predictions)