fasttext

fasttext

class hanlp.layers.embeddings.fast_text.FastTextEmbedding(src: str, filepath: str)[source]

An embedding layer builder for fastText (Bojanowski et al. 2017).

Parameters
  • src – Field name.

  • filepath – Filepath to pretrained fastText embeddings.

module(**kwargs) Optional[torch.nn.modules.module.Module][source]

Build a module for this embedding.

Parameters

**kwargs – Containing vocabs, training etc. Not finalized for now.

Returns

A module.

transform(**kwargs) Optional[Callable][source]

Build a transform function for this embedding.

Parameters

**kwargs – Containing vocabs, training etc. Not finalized for now.

Returns

A transform function.

class hanlp.layers.embeddings.fast_text.FastTextEmbeddingModule(key, embedding_dim: int)[source]

An embedding layer for fastText (Bojanowski et al. 2017).

Parameters
  • key – Field name.

  • embedding_dim – Size of this embedding layer