mirror of
https://github.com/hwchase17/langchain.git
synced 2025-09-09 15:03:21 +00:00
community[minor]: Add SparkLLM Text Embedding Model and SparkLLM introduction (#17573)
This commit is contained in:
11
docs/docs/integrations/providers/sparkllm.mdx
Normal file
11
docs/docs/integrations/providers/sparkllm.mdx
Normal file
@@ -0,0 +1,11 @@
|
||||
# SparkLLM
|
||||
|
||||
>[SparkLLM](https://xinghuo.xfyun.cn/spark) is a large-scale cognitive model independently developed by iFLYTEK.
|
||||
It has cross-domain knowledge and language understanding ability by learning a large amount of texts, codes and images.
|
||||
It can understand and perform tasks based on natural dialogue.
|
||||
|
||||
## SparkLLM Chat Model
|
||||
An example is available at [example](/docs/integrations/chat/sparkllm).
|
||||
|
||||
## SparkLLM Text Embedding Model
|
||||
An example is available at [example](/docs/integrations/text_embedding/sparkllm)
|
90
docs/docs/integrations/text_embedding/sparkllm.ipynb
Normal file
90
docs/docs/integrations/text_embedding/sparkllm.ipynb
Normal file
@@ -0,0 +1,90 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"# SparkLLM Text Embeddings"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"Official Website: https://www.xfyun.cn/doc/spark/Embedding_new_api.html\n",
|
||||
"\n",
|
||||
"An API key is required to use this embedding model. You can get one by registering at https://platform.SparkLLM-ai.com/docs/text-Embedding."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"SparkLLMTextEmbeddings support 2K token window and preduces vectors with 2560 dimensions."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"from langchain_community.embeddings import SparkLLMTextEmbeddings\n",
|
||||
"\n",
|
||||
"embeddings = SparkLLMTextEmbeddings(\n",
|
||||
" spark_app_id=\"sk-*\", spark_api_key=\"\", spark_api_secret=\"\"\n",
|
||||
")"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"Alternatively, you can set API key this way:"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import os\n",
|
||||
"\n",
|
||||
"os.environ[\"SPARK_APP_ID\"] = \"YOUR_APP_ID\"\n",
|
||||
"os.environ[\"SPARK_API_KEY\"] = \"YOUR_API_KEY\"\n",
|
||||
"os.environ[\"SPARK_API_SECRET\"] = \"YOUR_API_SECRET\""
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"text_1 = \"iFLYTEK is a well-known intelligent speech and artificial intelligence publicly listed company in the Asia-Pacific Region. Since its establishment, the company is devoted to cornerstone technological research in speech and languages, natural language understanding, machine learning, machine reasoning, adaptive learning, and has maintained the world-leading position in those domains. The company actively promotes the development of A.I. products and their sector-based applications, with visions of enabling machines to listen and speak, understand and think, creating a better world with artificial intelligence.\"\n",
|
||||
"text_2 = \"iFLYTEK Open Platform was launched in 2010 by iFLYTEK as China’s first Artificial Intelligence open platform for Mobile Internet and intelligent hardware developers.\"\n",
|
||||
"\n",
|
||||
"query_result = embeddings.embed_query(text_2)\n",
|
||||
"query_result"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"doc_result = embeddings.embed_documents([text_1, text_2])\n",
|
||||
"doc_result"
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"language_info": {
|
||||
"name": "python"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 2
|
||||
}
|
Reference in New Issue
Block a user