-
Notifications
You must be signed in to change notification settings - Fork 721
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add model 2024-11-20-bert_embeddings_sec_bert_base_en (#14460)
Co-authored-by: gadde5300 <gadde5300@gmail.com>
- Loading branch information
1 parent
30b478f
commit 9e3bea1
Showing
1 changed file
with
105 additions
and
0 deletions.
There are no files selected for viewing
105 changes: 105 additions & 0 deletions
105
docs/_posts/gadde5300/2024-11-20-bert_embeddings_sec_bert_base_en.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
--- | ||
layout: model | ||
title: Financial English BERT Embeddings (Base) | ||
author: John Snow Labs | ||
name: bert_embeddings_sec_bert_base | ||
date: 2024-11-20 | ||
tags: [financial, bert, en, embeddings, open_source, tensorflow] | ||
task: Embeddings | ||
language: en | ||
edition: Spark NLP 5.5.1 | ||
spark_version: 3.0 | ||
supported: true | ||
engine: tensorflow | ||
annotator: BertEmbeddings | ||
article_header: | ||
type: cover | ||
use_language_switcher: "Python-Scala-Java" | ||
--- | ||
|
||
## Description | ||
|
||
Financial Pretrained BERT Embeddings model, uploaded to Hugging Face, adapted and imported into Spark NLP. `sec-bert-base` is a English model orginally trained by `nlpaueb`. This is the reference base model, what means it uses the same architecture as BERT-BASE trained on financial documents. | ||
|
||
## Predicted Entities | ||
|
||
|
||
|
||
{:.btn-box} | ||
<button class="button button-orange" disabled>Live Demo</button> | ||
<button class="button button-orange" disabled>Open in Colab</button> | ||
[Download](https://s3.amazonaws.com/auxdata.johnsnowlabs.com/public/models/bert_embeddings_sec_bert_base_en_5.5.1_3.0_1732064992710.zip){:.button.button-orange.button-orange-trans.arr.button-icon} | ||
[Copy S3 URI](s3://auxdata.johnsnowlabs.com/public/models/bert_embeddings_sec_bert_base_en_5.5.1_3.0_1732064992710.zip){:.button.button-orange.button-orange-trans.button-icon.button-copy-s3} | ||
|
||
## How to use | ||
|
||
|
||
|
||
<div class="tabs-box" markdown="1"> | ||
{% include programmingLanguageSelectScalaPythonNLU.html %} | ||
```python | ||
documentAssembler = DocumentAssembler() \ | ||
.setInputCol("text") \ | ||
.setOutputCol("document") | ||
|
||
tokenizer = Tokenizer() \ | ||
.setInputCols("document") \ | ||
.setOutputCol("token") | ||
|
||
embeddings = BertEmbeddings.pretrained("bert_embeddings_sec_bert_base","en") \ | ||
.setInputCols(["document", "token"]) \ | ||
.setOutputCol("embeddings") | ||
|
||
pipeline = Pipeline(stages=[documentAssembler, tokenizer, embeddings]) | ||
|
||
data = spark.createDataFrame([["I love Spark NLP"]]).toDF("text") | ||
|
||
result = pipeline.fit(data).transform(data) | ||
``` | ||
```scala | ||
val documentAssembler = new DocumentAssembler() | ||
.setInputCol("text") | ||
.setOutputCol("document") | ||
|
||
val tokenizer = new Tokenizer() | ||
.setInputCols(Array("document")) | ||
.setOutputCol("token") | ||
|
||
val embeddings = BertEmbeddings.pretrained("bert_embeddings_sec_bert_base","en") | ||
.setInputCols(Array("document", "token")) | ||
.setOutputCol("embeddings") | ||
|
||
val pipeline = new Pipeline().setStages(Array(documentAssembler, tokenizer, embeddings)) | ||
|
||
val data = Seq("I love Spark NLP").toDF("text") | ||
|
||
val result = pipeline.fit(data).transform(data) | ||
``` | ||
|
||
{:.nlu-block} | ||
```python | ||
import nlu | ||
nlu.load("en.embed.sec_bert_base").predict("""I love Spark NLP""") | ||
``` | ||
</div> | ||
|
||
{:.model-param} | ||
## Model Information | ||
|
||
{:.table-model} | ||
|---|---| | ||
|Model Name:|bert_embeddings_sec_bert_base| | ||
|Compatibility:|Spark NLP 5.5.1+| | ||
|License:|Open Source| | ||
|Edition:|Official| | ||
|Input Labels:|[sentence, token]| | ||
|Output Labels:|[bert]| | ||
|Language:|en| | ||
|Size:|409.4 MB| | ||
|Case sensitive:|true| | ||
|
||
## References | ||
|
||
- https://huggingface.co/nlpaueb/sec-bert-base | ||
- https://arxiv.org/abs/2203.06482 | ||
- http://nlp.cs.aueb.gr/ |