Git Product home page Git Product logo

Comments (4)

nicola-decao avatar nicola-decao commented on May 24, 2024 1

Try:

def _get_entity_spans(
    model,
    input_sentences,
    prefix_allowed_tokens_fn,
    redirections=None,
):
    output_sentences = model.sample(
        input_sentences,
        prefix_allowed_tokens_fn=prefix_allowed_tokens_fn,
    )

    output_sentences = [e[0]["text"] for e in output_sentences]
   
    return get_entity_spans_finalize(
        input_sentences, output_sentences, redirections=redirections
    )

from genre.

loretoparisi avatar loretoparisi commented on May 24, 2024 1

It works perfectly thank you. I just added an import of from genre.utils import get_entity_spans_finalize.

from genre.

nicola-decao avatar nicola-decao commented on May 24, 2024

get_entity_spans first calls a pre-processing step on the inputs:

def get_entity_spans_pre_processing(sentences):
and then a post-processing step of the outputs:
def get_entity_spans_post_processing(sentences):
To get the same output you should do the same.

from genre.

loretoparisi avatar loretoparisi commented on May 24, 2024

@nicola-decao thank you. I would like that get_entity_spans had the same output of model.sample. Currently, the output of the latter (model.sample) seems to me more accurate than the former. So how to "force" get_entity_spans to have the same result of model.sample?

Examples

sentences = ["Tired of the lies? Tired of the spin? Are you ready to hear the hard-hitting truth in comprehensive, conservative, principled fashion? The Ben Shapiro Show brings you all the news you need to know in the most fast moving daily program in America. Ben brutally breaks down the culture and never gives an inch! Monday thru Friday."]

# model.sample
prefix_allowed_tokens_fn = get_prefix_allowed_tokens_fn(model, sentences)
out = model.sample(
    sentences,
    prefix_allowed_tokens_fn=prefix_allowed_tokens_fn,
)
print(out)

# get_entity_spans
entity_spans = get_entity_spans( model, sentences)
print(get_markdown(sentences, entity_spans))

from genre.

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.