Skip to content

Commit 4ac11a0

Browse files
maziyarpanahijsl-modelsDevinTDHa
authored
Models hub (#14230)
Co-authored-by: ahmet-mesut <drmesutbirol@gmail.com> Co-authored-by: Ahmet Mesut BİROL <99045664+ahmet-mesut@users.noreply.github.com> * Add model 2024-04-05-uae_large_v1_en (#14229) Co-authored-by: DevinTDHa <duc.hatrung95@gmail.com> --------- Co-authored-by: jsl-models <74001263+jsl-models@users.noreply.github.com> Co-authored-by: DevinTDHa <duc.hatrung95@gmail.com> Co-authored-by: Devin Ha <33089471+DevinTDHa@users.noreply.github.com>
1 parent 4a37687 commit 4ac11a0

File tree

1 file changed

+120
-0
lines changed

1 file changed

+120
-0
lines changed
Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
---
2+
layout: model
3+
title: UAE-Large-V1 for Sentence Embeddings
4+
author: John Snow Labs
5+
name: uae_large_v1
6+
date: 2024-04-05
7+
tags: [uae, en, sentence, embeddings, open_source, onnx]
8+
task: Embeddings
9+
language: en
10+
edition: Spark NLP 5.3.3
11+
spark_version: 3.0
12+
supported: true
13+
engine: onnx
14+
annotator: UAEEmbeddings
15+
article_header:
16+
type: cover
17+
use_language_switcher: "Python-Scala-Java"
18+
---
19+
20+
## Description
21+
22+
UAE is a novel angle-optimized text embedding model, designed to improve semantic textual
23+
similarity tasks, which are crucial for Large Language Model (LLM) applications. By
24+
introducing angle optimization in a complex space, AnglE effectively mitigates saturation of
25+
the cosine similarity function.
26+
27+
This model is based on UAE-Large-V1 and was orignally exported from https://huggingface.co/WhereIsAI/UAE-Large-V1. Several embedding pooling strategies can be set. Please refer to the class for more information.
28+
29+
## Predicted Entities
30+
31+
32+
33+
{:.btn-box}
34+
<button class="button button-orange" disabled>Live Demo</button>
35+
<button class="button button-orange" disabled>Open in Colab</button>
36+
[Download](https://s3.amazonaws.com/auxdata.johnsnowlabs.com/public/models/uae_large_v1_en_5.3.3_3.0_1712335736995.zip){:.button.button-orange.button-orange-trans.arr.button-icon}
37+
[Copy S3 URI](s3://auxdata.johnsnowlabs.com/public/models/uae_large_v1_en_5.3.3_3.0_1712335736995.zip){:.button.button-orange.button-orange-trans.button-icon.button-copy-s3}
38+
39+
## How to use
40+
41+
42+
43+
<div class="tabs-box" markdown="1">
44+
{% include programmingLanguageSelectScalaPythonNLU.html %}
45+
```python
46+
import sparknlp
47+
from sparknlp.base import *
48+
from sparknlp.annotator import *
49+
from pyspark.ml import Pipeline
50+
documentAssembler = DocumentAssembler() \
51+
.setInputCol("text") \
52+
.setOutputCol("document")
53+
embeddings = UAEEmbeddings.pretrained() \
54+
.setInputCols(["document"]) \
55+
.setOutputCol("embeddings")
56+
embeddingsFinisher = EmbeddingsFinisher() \
57+
.setInputCols("embeddings") \
58+
.setOutputCols("finished_embeddings") \
59+
.setOutputAsVector(True)
60+
pipeline = Pipeline().setStages([
61+
documentAssembler,
62+
embeddings,
63+
embeddingsFinisher
64+
])
65+
data = spark.createDataFrame([["hello world", "hello moon"]]).toDF("text")
66+
result = pipeline.fit(data).transform(data)
67+
result.selectExpr("explode(finished_embeddings) as result").show(5, 80)
68+
```
69+
```scala
70+
import spark.implicits._
71+
import com.johnsnowlabs.nlp.base.DocumentAssembler
72+
import com.johnsnowlabs.nlp.annotators.Tokenizer
73+
import com.johnsnowlabs.nlp.embeddings.UAEEmbeddings
74+
import com.johnsnowlabs.nlp.EmbeddingsFinisher
75+
import org.apache.spark.ml.Pipeline
76+
val documentAssembler = new DocumentAssembler()
77+
.setInputCol("text")
78+
.setOutputCol("document")
79+
val embeddings = UAEEmbeddings.pretrained()
80+
.setInputCols("document")
81+
.setOutputCol("UAE_embeddings")
82+
val embeddingsFinisher = new EmbeddingsFinisher()
83+
.setInputCols("UAE_embeddings")
84+
.setOutputCols("finished_embeddings")
85+
.setOutputAsVector(true)
86+
val pipeline = new Pipeline().setStages(Array(
87+
documentAssembler,
88+
embeddings,
89+
embeddingsFinisher
90+
))
91+
val data = Seq("hello world", "hello moon").toDF("text")
92+
val result = pipeline.fit(data).transform(data)
93+
result.selectExpr("explode(finished_embeddings) as result").show(5, 80)
94+
```
95+
</div>
96+
97+
## Results
98+
99+
```bash
100+
+--------------------------------------------------------------------------------+
101+
| result|
102+
+--------------------------------------------------------------------------------+
103+
|[0.50387806, 0.5861606, 0.35129607, -0.76046336, -0.32446072, -0.117674336, 0...|
104+
|[0.6660665, 0.961762, 0.24854276, -0.1018044, -0.6569202, 0.027635604, 0.1915...|
105+
+--------------------------------------------------------------------------------+
106+
```
107+
108+
{:.model-param}
109+
## Model Information
110+
111+
{:.table-model}
112+
|---|---|
113+
|Model Name:|uae_large_v1|
114+
|Compatibility:|Spark NLP 5.3.3+|
115+
|License:|Open Source|
116+
|Edition:|Official|
117+
|Input Labels:|[document]|
118+
|Output Labels:|[embeddings]|
119+
|Language:|en|
120+
|Size:|1.2 GB|

0 commit comments

Comments
 (0)