赞
踩
截至到2024年初,业界已经出现了多个大型语言模型,这些模型在自然语言处理(NLP)、生成文本、理解和推理等方面表现出色。以下是一些知名的大模型及其特点:
1. **GPT-4 (OpenAI)**
- 特点:GPT-4是OpenAI推出的最新一代大型语言模型,继承了GPT-3的强大能力,并在理解深度、文本生成的自然性和准确性等方面进行了显著改进。GPT-4能够更好地理解上下文,生成更加连贯和准确的文本,同时在一些特定的任务上表现得像专家一样熟练。
- 应用场景:内容创作、聊天机器人、编程辅助、教育、游戏设计等。2. **LaMDA (Google)**
- 特点:LaMDA是Google开发的一种对话型语言模型,专为生成更自然、更流畅的对话而设计。LaMDA的特点在于其能够维持长时间的对话,理解复杂的对话上下文,并生成相关且连贯的回复。
- 应用场景:虚拟助手、客户服务机器人、娱乐和游戏中的对话生成等。3. **ERNIE (百度)**
- 特点:ERNIE是百度开发的一系列语言理解模型,通过融合知识图谱和大规模文本数据训练,ERNIE能够更好地理解语言中的实体和它们之间的关系。ERNIE在一些特定的NLP任务上,如问答系统和语义理解方面,展现出优异的性能。
- 应用场景:搜索引擎、问答系统、个性化推荐等。4. **Jurassic-1 (AI21 Labs)**
- 特点:Jurassic-1是AI21 Labs开发的大型语言模型,旨在提供更高质量的文本生成和理解能力。Jurassic-1在处理复杂的文本理解和生成任务时表现出色,能够生成高质量、多样化的文本内容。
- 应用场景:内容创作、数据分析、自动摘要、教育辅导等。5. **BLOOM (Hugging Face)**
- 特点:BLOOM是由Hugging Face领导的一个开源项目,旨在创建一个多语言、高性能的大型语言模型。BLOOM特别注重多语言能力和开放性,支持多种语言,旨在为全球用户提供高质量的语言模型服务。
- 应用场景:多语言文本生成、自动翻译、跨文化交流辅助等。这些模型各有特色,它们在不同的任务和应用场景中展现出各自的优势。随着技术的不断进步,未来可能会出现更多功能更强大、应用更广泛的语言模型。
那我们如何使用呢
大名鼎鼎的spring它怎么可能不会呢,去看看它的官网吧
Spring AI 最初的重点是处理语言输入并提供语言输出的模型,最初是 OpenAI + Azure OpenAI。上表中的最后一行接受文本作为输入和输出数字,通常称为嵌入文本,表示 AI 模型中使用的内部数据结构。 Spring AI 支持嵌入,以支持更高级的用例。
该Spring AI
项目旨在简化包含人工智能功能的应用程序的开发,避免不必要的复杂性。
该项目从著名的 Python 项目(例如 LangChain 和 LlamaIndex)中汲取灵感,但 Spring AI 并不是这些项目的直接移植。该项目的成立相信下一波生成式人工智能应用程序不仅适用于 Python 开发人员,而且将在许多编程语言中普遍存在。
Spring AI 的核心提供了抽象,作为开发 AI 应用程序的基础。这些抽象有多种实现,可以通过最少的代码更改轻松进行组件交换。
Spring AI 提供以下功能:
支持所有主要模型提供商,例如 OpenAI、Microsoft、Amazon、Google 和 Huggingface。
支持的模型类型包括“聊天”和“文本到图像”,还有更多模型类型正在开发中。
跨 AI 提供商的可移植 API,用于聊天和嵌入模型。支持同步和流 API 选项。还支持下拉访问模型特定功能。
AI 模型输出到 POJO 的映射。
支持所有主要矢量数据库提供商,例如 Apache Cassandra、Azure 矢量搜索、Chroma、Milvus、Neo4j、PostgreSQL/PGVector、PineCone、Qdrant、Redis 和 Weaviate
跨 Vector Store 提供商的可移植 API,包括同样可移植的新颖的类似 SQL 的元数据过滤器 API。
函数调用
AI 模型和向量存储的 Spring Boot 自动配置和启动器。
数据工程的 ETL 框架
简单DEMO演示
环境 idea jdk 17 maven
引入pom
- <?xml version="1.0" encoding="UTF-8"?>
- <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-starter-parent</artifactId>
- <version>3.2.3</version>
- <relativePath/> <!-- lookup parent from repository -->
- </parent>
- <groupId>com.example</groupId>
- <artifactId>ai-openai-helloworld</artifactId>
- <version>0.0.1-SNAPSHOT</version>
- <name>ai-openai-helloworld</name>
- <description>Simple AI Application using bOpenAPI Service</description>
- <properties>
- <java.version>17</java.version>
- </properties>
-
- <dependencyManagement>
- <dependencies>
- <dependency>
- <groupId>org.springframework.ai</groupId>
- <artifactId>spring-ai-bom</artifactId>
- <version>0.8.1</version>
- <type>pom</type>
- <scope>import</scope>
- </dependency>
- </dependencies>
- </dependencyManagement>
-
- <dependencies>
- <dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-starter-web</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-starter-actuator</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.springframework.ai</groupId>
- <artifactId>spring-ai-openai-spring-boot-starter</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-starter-test</artifactId>
- <scope>test</scope>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-maven-plugin</artifactId>
- </plugin>
- </plugins>
- </build>
-
- <repositories>
- <repository>
- <id>spring-milestones</id>
- <name>Spring Milestones</name>
- <url>https://repo.spring.io/milestone</url>
- <snapshots>
- <enabled>false</enabled>
- </snapshots>
- </repository>
- <repository>
- <id>spring-snapshots</id>
- <name>Spring Snapshots</name>
- <url>https://repo.spring.io/snapshot</url>
- <releases>
- <enabled>false</enabled>
- </releases>
- </repository>
- </repositories>
-
-
- </project>
- @RestController
- public class SimpleAiController {
-
- private final ChatClient chatClient;
-
- @Autowired
- public SimpleAiController(ChatClient chatClient) {
- this.chatClient = chatClient;
- }
-
- @GetMapping("/ai/simple")
- public Map<String, String> completion(@RequestParam(value = "message", defaultValue = "Tell me a joke") String message) {
- return Map.of("generation", chatClient.call(message));
- }
- }
- package org.springframework.ai.openai.samples.helloworld;
-
- import org.springframework.boot.SpringApplication;
- import org.springframework.boot.autoconfigure.SpringBootApplication;
-
- @SpringBootApplication
- public class Application {
-
- public static void main(String[] args) {
- SpringApplication.run(Application.class, args);
- }
-
- }
spring.ai.openai.api-key=API-KEY
API-KEY某宝购买
访问方式:http://localhost:8080/ai/simple?message = "你是谁"
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。