华为Could API人工智能系列——句向量
华为Could API人工智能系列——句向量
前言
云原生时代,开发者们的编程方式、编程习惯都发生了天翻地覆的变化,大家逐渐地习惯在云端构建自己的应用。作为新一代的开发者们,如何更快速了解云,学习云,使用云,更便捷、更智能的开发代码,从而提升我们的开发效率,是当前最热门的话题之一,而Huawei Cloud Toolkit,作为连接华为云的百宝箱,是集成在各大IDE平台上的插件集合,会在方方面面提升着开发者的效率。
华为云API开发套件助力开发者快速集成华为云,可做到便捷连接200+的华为云服务,引用7000+的华为云API服务,在IDE中集成华为云的功能,让开发者与云端华为云建立连接。
智能编码方面集成了华为云自主研发的代码大模型和软件分析技术,全场景函数级、行级代码生成,同规模算力一次通过业界第一,这会帮助开发者更为高效的使用自动语义生成,达到快速开发的目的,使整个过程更智能。
环境准备
开发语言:Python
开发工具:PyCharm Community Edition 2023.1.4
PyCharm插件:
1、Chinese (Simplified) Language Pack /中文语言包
2、Huawei Cloud API:华为云API插件提供华为云服务全量API检索、调试、SDK代码自动补全、集成华为云CLI、示例代码等功能
3、Huawei Cloud CodeArts Check:华为云代码检查插件提供业界规范(含华为云)检查,支持一键格式化和代码自动修复,当前支持Java、C++、C,这个使您使用的环境操作即可,我这里用的python没有提示。
4、Huawei Cloud CodeArts Snap:华为云 CodeArt Snap 智能编程助手致力于打造现代化开发新范式,通过将自然语言转化为规范可阅读、无开源漏洞的编程语言,提升开发者编码效率,助力企业快速响应市场不确定性;
5、Huawei Cloud Toolkit Platform:华为云底座插件为华为云各类云服务插件提供公共能力,比如单点登录、UI集成、API访问等功能;
PyCharm环境的搭建:https://laoshifu.blog.csdn.net/article/details/135279145
API接口开通地址:https://console.huaweicloud.com/nlp/#/nlp/overview
句向量
输入句子,返回对应的句向量。
开通地址:https://console.huaweicloud.com/nlp/#/nlp/overview
开通效果:
请求参数
名称 |
类型 |
IN |
必选 |
描述 |
|
X-Auth-Token |
string |
header |
true |
用户Token。 通过调用IAM服务获取用户Token接口获取(响应消息头中X-Subject-Token的值)。 |
|
project_id |
string |
path |
true |
来自公有云的Project ID,用于资源隔离。 |
Body 参数
名称 |
类型 |
必选 |
描述 |
|
sentences |
Array of strings |
true |
文本列表,文本长度为1~512,列表大小为1~1000,文本编码为UTF-8。 |
|
domain |
string |
false |
支持的领域类型,目前只支持通用领域,默认为general。 |
返回参数
名称 |
类型 |
必选 |
描述 |
|
vectors |
Array<Array<Float>> |
false |
句向量结果列表,按输入句子顺序返回句向量。调用失败时无此字段。 |
|
error_code |
string |
false |
调用失败时的错误码,具体请参见错误码。调用成功时无此字段。 |
|
error_msg |
string |
false |
调用失败时的错误信息。调用成功时无此字段。 |
API调试
测试参数:
{
"sentences": [
"今天是星期六,又能吃成长快乐了。",
"今天是星期一,不能吃成长快乐了。"
],
"domain": "general"
}
测试操作:
返回结果:
{
"vectors": [
[
-4.191368451818182,
1.256696386363637,
-0.1757676727272729,
1.3186143797272722,
-3.708946781818182,
2.727557118181818,
-0.4690321727272728,
-0.8754485872727273,
0.49066961672727294,
-2.887992647272728,
2.9592263727272727,
-2.7302838818181816,
-1.2190484499999998,
-0.8519662572727273,
1.9459478499999998,
2.616825681818182,
0.8846167454545455,
-0.5071119972727272,
-4.274560027272727,
4.425354181818182,
3.5557722550909094,
-3.9373808336363636,
0.2479371954545454,
-1.8826973454545455,
0.7980312427272725,
3.374172414545455,
-1.5537963745454546,
-3.1576818909090916,
-0.522588429090909,
1.969290678181818,
-0.2946356981818181,
-2.9669148636363634,
-2.85718554,
-3.9337230727272727,
0.41961988318181814,
-2.846807081818182,
2.7116002545454543,
-1.2531877681818184,
1.6347230863636368,
4.455486981818182,
-4.475194433636364,
-0.9565395181818179,
-0.29094723781818177,
-3.904557045454545,
-2.9757591736363636,
-0.28553659454545466,
7.558256763636364,
-2.5598209318181815,
1.418183490909091,
-0.9254761181818182,
-0.2647301890909093,
2.241759145454546,
4.796657491272727,
4.635508506363636,
-1.1837203581818179,
-2.8704023454545453,
5.599937372727273,
-0.1344964954545456,
-2.763777781818182,
-3.2410769909090913,
-2.0412254272727277,
-1.4528391590909089,
0.9091141218181817,
-0.3498828363636363,
-2.479100141818182,
-0.9908890454545456,
3.3349622290909084,
0.6612452554545455,
3.4962065327272724,
0.13121356636363635,
2.7538735681818185,
-1.59813097,
5.829920041818183,
1.6935644436363637,
3.0202612909090907,
0.6610354472727272,
3.352918651818182,
4.575759172727273,
4.993428436445455,
-5.243246700909091,
1.3564841305454547,
1.4126846318181818,
-3.695441501818182,
1.19425346,
-1.5421971845454543,
4.080592340545454,
6.424804690909091,
2.5253682363636365,
3.6448938930909094,
-0.5029370545454547,
-5.469685689090909,
-1.4931417972727272,
2.945062743909091,
-6.1784808540909095,
-4.456382909090909,
3.4529553936363637,
1.145512390909091,
4.713673109090909,
7.117483129090909,
-1.1022293218181816
],
[
-4.237295397272726,
1.608423813636364,
1.019426327272727,
1.2477870224545453,
-4.420414145454545,
4.1045290727272725,
-0.2749083272727271,
-0.7624580545454545,
0.12291138881818182,
-2.142405650909091,
3.024190372727273,
-3.339940536363636,
-0.37011289545454534,
-0.8225383445454544,
1.437915327272727,
2.8237574818181814,
1.022668272727273,
-0.4582060518181818,
-3.6967128986363633,
5.6357219363636375,
3.921972518727273,
-5.484527088181818,
-0.342810231818182,
-0.8771504090909094,
-0.19418829363636378,
2.703319696363636,
-0.7984195472727275,
-3.5664326181818184,
0.008305998545454652,
2.45160606,
-0.7709713618181819,
-2.566321269090909,
-2.8985508063636365,
-3.221960336363636,
0.10947177409090916,
-3.607892336363636,
1.9636017909090908,
-0.8845678812727272,
2.2199143454545456,
3.920804466363637,
-5.808092233636364,
-1.8732714672727275,
0.1631208912727273,
-3.3407676596363634,
-2.3379803554545453,
0.3123417463636362,
7.7140134381818175,
-2.298213054545454,
1.5382798181818182,
-0.503386359090909,
-0.10414060090909101,
1.693940981818182,
4.930588048181818,
4.286539742727272,
-1.936116985454545,
-2.159810309090909,
6.7762325363636355,
0.285327640909091,
-3.8227973000000004,
-3.640228266363637,
-1.9011199545454545,
-1.3009565754545456,
0.6038001072727274,
0.11443120000000005,
-3.1657345599999998,
-1.856442463636364,
3.4315681309090906,
-0.06433059000000024,
3.8859037236363636,
-0.3986969700000001,
2.5786801300000004,
-2.6963184518181817,
5.293465996363637,
2.9939724072727274,
3.740396627272727,
1.5783553290909091,
3.922122372727273,
4.730493200000001,
5.390343654545455,
-6.433333846363637,
0.06926653963636378,
0.8186471209090908,
-4.705059063636363,
0.4034271199999999,
-0.013125299090909063,
4.4970059576909085,
6.082637872727273,
2.3993913204545456,
4.167472292181819,
-0.18022451818181826,
-6.1637585527272725,
-1.3489778836363635,
3.305130034818181,
-6.475965106818182,
-4.707149427272728,
5.333865272727272,
0.8917211727272726,
5.481132736363637,
7.031756181818182,
-0.017224740000000013
]
]
}
我的天啊,这向量给了这么多,不好分析啊,暂时不太理解理解能力强的可以分析一下。
本地测试
这里需要AK与SK来测试。
本地测试成功,但是向量数据依然需要自行理解。
- 点赞
- 收藏
- 关注作者
评论(0)