This is a RoBERTa model pre-trained on Coptic Scriptorium Corpora for POS-tagging and dependency-parsing (using
goeswith
for subwords), derived from
roberta-base-coptic
.
How to Use
classUDgoeswith(object):
def__init__(self,bert):
from transformers import AutoTokenizer,AutoModelForTokenClassification
self.tokenizer=AutoTokenizer.from_pretrained(bert)
self.model=AutoModelForTokenClassification.from_pretrained(bert)
def__call__(self,text):
import numpy,torch,ufal.chu_liu_edmonds
w=self.tokenizer(text,return_offsets_mapping=True)
v=w["input_ids"]
x=[v[0:i]+[self.tokenizer.mask_token_id]+v[i+1:]+[j] for i,j inenumerate(v[1:-1],1)]
with torch.no_grad():
e=self.model(input_ids=torch.tensor(x)).logits.numpy()[:,1:-2,:]
r=[1if i==0else -1if j.endswith("|root") else0for i,j insorted(self.model.config.id2label.items())]
e+=numpy.where(numpy.add.outer(numpy.identity(e.shape[0]),r)==0,0,numpy.nan)
g=self.model.config.label2id["X|_|goeswith"]
r=numpy.tri(e.shape[0])
for i inrange(e.shape[0]):
for j inrange(i+2,e.shape[1]):
r[i,j]=r[i,j-1] if numpy.nanargmax(e[i,j-1])==g else1
e[:,:,g]+=numpy.where(r==0,0,numpy.nan)
m=numpy.full((e.shape[0]+1,e.shape[1]+1),numpy.nan)
m[1:,1:]=numpy.nanmax(e,axis=2).transpose()
p=numpy.zeros(m.shape)
p[1:,1:]=numpy.nanargmax(e,axis=2).transpose()
for i inrange(1,m.shape[0]):
m[i,0],m[i,i],p[i,0]=m[i,i],numpy.nan,p[i,i]
h=ufal.chu_liu_edmonds.chu_liu_edmonds(m)[0]
if [0for i in h if i==0]!=[0]:
m[:,0]+=numpy.where(m[:,0]==numpy.nanmax(m[[i for i,j inenumerate(h) if j==0],0]),0,numpy.nan)
m[[i for i,j inenumerate(h) if j==0]]+=[0if i==0or j==0else numpy.nan for i,j inenumerate(h)]
h=ufal.chu_liu_edmonds.chu_liu_edmonds(m)[0]
u="# text = "+text+"\n"
v=[(s,e) for s,e in w["offset_mapping"] if s<e]
for i,(s,e) inenumerate(v,1):
q=self.model.config.id2label[p[i,h[i]]].split("|")
u+="\t".join([str(i),text[s:e],"_",q[0],"_","|".join(q[1:-1]),str(h[i]),q[-1],"_","_"if i<len(v) and e<v[i][0] else"SpaceAfter=No"])+"\n"return u+"\n"
nlp=UDgoeswith("KoichiYasuoka/roberta-base-coptic-ud-goeswith")
print(nlp("ⲧⲉⲛⲟⲩⲇⲉⲛ̄ⲟⲩⲟⲉⲓⲛϩ︤ⲙ︥ⲡϫⲟⲉⲓⲥ·"))
roberta-base-coptic-ud-goeswith huggingface.co is an AI model on huggingface.co that provides roberta-base-coptic-ud-goeswith's model effect (), which can be used instantly with this KoichiYasuoka roberta-base-coptic-ud-goeswith model. huggingface.co supports a free trial of the roberta-base-coptic-ud-goeswith model, and also provides paid use of the roberta-base-coptic-ud-goeswith. Support call roberta-base-coptic-ud-goeswith model through api, including Node.js, Python, http.
roberta-base-coptic-ud-goeswith huggingface.co is an online trial and call api platform, which integrates roberta-base-coptic-ud-goeswith's modeling effects, including api services, and provides a free online trial of roberta-base-coptic-ud-goeswith, you can try roberta-base-coptic-ud-goeswith online for free by clicking the link below.
KoichiYasuoka roberta-base-coptic-ud-goeswith online free url in huggingface.co:
roberta-base-coptic-ud-goeswith is an open source model from GitHub that offers a free installation service, and any user can find roberta-base-coptic-ud-goeswith on GitHub to install. At the same time, huggingface.co provides the effect of roberta-base-coptic-ud-goeswith install, users can directly use roberta-base-coptic-ud-goeswith installed effect in huggingface.co for debugging and trial. It also supports api for free installation.
roberta-base-coptic-ud-goeswith install url in huggingface.co: