Documentation
¶
Overview ¶
Implementation of a sequence labeling architecture composed by Embeddings -> BiRNN -> Scorer -> CRF.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Convert ¶
Convert converts the parameters (weights and bias) of a pre-processed Flair model into spaGO structures. At this moment it is not possible to import directly from the Flair model: a simple Python script takes care of pre-processing and exporting the tensors in a format more compatible with spaGO. I'll make that script available soon, now it's a bit chaotic. In the future it would be even better to import directly from Flair.
Types ¶
type Body ¶
type Body struct { Options OptionsType `json:"options"` Text string `json:"text"` }
type Config ¶
type Config struct { ModelFilename string `json:"model_filename"` WordEmbeddings WordEmbeddingsConfig `json:"word_embeddings"` WordEmbeddings2 WordEmbeddingsConfig `json:"word_embeddings_2"` ContextualStringEmbeddings ContextualEmbeddingsConfig `json:"contextual_string_embeddings"` EmbeddingsProjectionInputSize int `json:"embeddings_projection_input_size"` EmbeddingsProjectionOutputSize int `json:"embeddings_projection_output_size"` RecurrentInputSize int `json:"recurrent_input_size"` RecurrentOutputSize int `json:"recurrent_output_size"` ScorerInputSize int `json:"scorer_input_size"` ScorerOutputSize int `json:"scorer_output_size"` Labels []string `json:"labels"` }
func LoadConfig ¶
type ContextualEmbeddingsConfig ¶
type ContextualEmbeddingsConfig struct { VocabularySize int `json:"vocabulary_size"` EmbeddingSize int `json:"embedding_size"` HiddenSize int `json:"hidden_size"` OutputSize int `json:"output_size"` SequenceSeparator string `json:"sequence_separator"` UnknownToken string `json:"unknown_token"` VocabularyFilename string `json:"vocabulary_filename"` }
type Model ¶
type Model struct { Config Config EmbeddingsLayer *stackedembeddings.Model TaggerLayer *birnncrf.Model Labels []string }
func NewDefaultModel ¶
func NewDefaultModel(config Config, path string, readOnlyEmbeddings bool, forceNewEmbeddingsDB bool) *Model
NewDefaultModel returns a new sequence labeler built based on the architecture of Flair. See https://github.com/flairNLP/flair for more information.
func (*Model) LoadParams ¶
func (*Model) LoadVocabulary ¶
type OptionsType ¶
type Processor ¶
type Processor struct { nn.BaseProcessor EmbeddingsLayer *stackedembeddings.Processor TaggerLayer *birnncrf.Processor }
func (*Processor) NegativeLogLoss ¶
TODO: it could be more consistent if the targets were the string labels
func (*Processor) Predict ¶
func (p *Processor) Predict(tokens []tokenizers.StringOffsetsPair) []TokenLabel
type Response ¶
type Server ¶
type Server struct { // UnimplementedSequenceLabelerServer must be embedded to have forward compatible implementations for gRPC. grpcapi.UnimplementedSequenceLabelerServer // contains filtered or unexported fields }
func (*Server) Analyze ¶
func (s *Server) Analyze(ctx context.Context, req *grpcapi.AnalyzeRequest) (*grpcapi.AnalyzeReply, error)
Sends a request to /analyze. TODO(evanmcclure@gmail.com) Reuse the gRPC message type for HTTP requests.
type TokenLabel ¶
type TokenLabel struct { tokenizers.StringOffsetsPair Label string }