BERT model fine-tuned on chilean STEM lessons
Project description
BERT-STEM
BERT model fine-tuned on Science Technology Engineering and Mathematics (STEM) lessons.
Install:
To install from pip:
pip install bertstem
Quickstart
To encode sentences and get embedding matrix for embedding layers:
from BERT_STEM.BertSTEM import *
bert = BertSTEM()
# Example dataframe with text in spanish
data = {'col_1': [3, 2, 1],
'col_2': ['hola como estan', 'alumnos queridos', 'vamos a hablar de matematicas']}
df = pd.DataFrame.from_dict(data)
# Encode sentences using BertSTEM:
bert._encode_df(df, column='col_2', encoding='sum')
# Get embedding matrix:
embedding_matrix = bert.get_embedding_matrix()
To use it from HuggingFace:
from BERT_STEM.Encode import *
import pandas as pd
import transformers
# Download spanish BERTSTEM:
model = transformers.BertModel.from_pretrained("pablouribe/bertstem")
# Download spanish tokenizer:
tokenizer = transformers.BertTokenizerFast.from_pretrained("dccuchile/bert-base-spanish-wwm-uncased",
do_lower_case=True,
add_special_tokens = False)
# Example dataframe with text in spanish
data = {'col_1': [3, 2, 1],
'col_2': ['hola como estan', 'alumnos queridos', 'vamos a hablar de matematicas']}
df = pd.DataFrame.from_dict(data)
# Encode sentences using BertSTEM:
sentence_encoder(df, model, tokenizer, column = 'col_2', encoding = 'sum')
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
bertstem-0.0.12.tar.gz
(5.6 kB
view hashes)
Built Distribution
Close
Hashes for bertstem-0.0.12-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 034c14fd7226a78f99b26e2da61c3f13cfccae0594726b35ac91c1b19e1b8e1a |
|
MD5 | 506d46c2fb6c7c18d2e6cecf728b191e |
|
BLAKE2b-256 | 5eef85e04b2f0e31f0de0bf7253f6d98d5845871bea14285ad9864a2fdd865a8 |