Skip to content

GENRE

Regen is based on GENRE. GENRE is also an entity linking model released by Facebook, but in this case it uses a different approach by conseidering the NERC task as a sequence-to-sequence problem, and retrieves the entities by using a constrained beam search to force the model to generate the entities.

In a nutshell, (m)GENRE uses a sequence-to-sequence approach to entity retrieval (e.g., linking), based on fine-tuned BART. GENRE performs retrieval generating the unique entity name conditioned on the input text using constrained beam search to only generate valid identifiers. Although there is a version end-to-end of GENRE, it is not currently supported on ZShot (but it will).

The REGEN linker will use the entities specified in the zshot.PipelineConfig.

Bases: Linker

REGEN linker

Parameters:

Name Type Description Default
max_input_len

Max length of input

384
max_output_len

Max length of output

15
num_beams

Number of beans to use

10
trie

If the trie is given the linker will use it to restrict the search space. Custom entities won't be used if the trie is given.

None

load_models()

Load Model

load_tokenizer()

Load Tokenizer

predict(docs, batch_size=None)

Perform the entity prediction

Parameters:

Name Type Description Default
docs Iterator[Doc]

A list of spacy Document

required
batch_size Optional[Union[int, None]]

The batch size

None

Returns:

Type Description
List[List[Span]]

List Spans for each Document in docs

restrict_decode_vocab(_, prefix_beam)

Restrict the possibilities of the Beam search to force the text generation

set_kg(entities)

Set new entities

Parameters:

Name Type Description Default
entities Iterator[Entity]

New entities to use

required