Code Monkey home page Code Monkey logo

Comments (4)

Tongjilibo avatar Tongjilibo commented on June 1, 2024

可以直接参考evaluate的内容的,可以解析得到start, end,和实体类别,这样你直接把这段tokens decode一下就能拿到对应的实体内容了

from bert4torch.

Echo-she avatar Echo-she commented on June 1, 2024

是类似下面代码这样子的吗:model.eval()
with torch.no_grad():
pp = model(text_tokenizer['input_ids'].to(device))[0].cpu()

scores = pp
threshold = 0.5
mapping = offset_mapping

for i, score in enumerate(scores):
R = set()
for start, end in zip(*np.where(score.cpu() > threshold)):
R.add((start, end, categories_id2label[i]))
print(R)

from bert4torch.

Tongjilibo avatar Tongjilibo commented on June 1, 2024

和你写的差不多,我这里增加了一个inference的函数,供参考

from bert4torch.

Echo-she avatar Echo-she commented on June 1, 2024

好的,感谢大佬

from bert4torch.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.