微信扫码
添加专属顾问
我要投稿
llmware 是一个集成框架,具有 50+ 多个小型、专业、开源模型, 用于快速开发基于 LLM 的应用程序,包括 Retrieval Augmented Generation (RAG) 和代理工作流的多步骤编排。
该项目提供了一套全面的工具,任何人都可以使用,从初学者到最老练的 AI 开发人员,都可以快速构建工业级、基于知识的企业 LLM 应用程序。
llmware 提供一个统一的框架,用于构建基于 LLM 的应用程序(例如 RAG、代理), 使用小型专用模型,这些模型可以私密部署,安全可靠地与企业知识库集成,并且经济高效地调整和适应任何业务流程。
llmware 有两个主要组件:
• RAG Pipeline - 用于将知识源连接到生成式 AI 模型的整个生命周期的集成组件;和
• 50+ 小型专用模型,针对企业流程自动化中的关键任务进行了微调,包括基于事实的问答、分类、总结和提取。
通过将这两个组件结合在一起,并集成领先的开源模型和底层技术,提供了一套全面的工具来快速构建基于知识的企业 LLM 应用程序。llmware
llmware 的主要组件包括:
• Model Catalog
• RAG Optimized Models
• Agents
• SLIM Models
• Embedding Models
• Library
• Query
• Data Stores
• Prompt with Sources
• Vector Databases
• Agent Inference Server
• GGUF
通过这些组件可以实现我们 RAG 应用中的所有功能。下面简单介绍一下。
通过轻松查找以相同的方式访问所有模型,而不管底层实现如何。
• 目录中的 150+ 型号,包括 50+ RAG 优化模型
• 18 个用于 Agent 用例的 SLIM 函数调用小语言模型
• 完全支持 GGUF、HuggingFace、Sentence Transformers 和基于 API 的主要模型
• 易于扩展以添加自定义模型
from llmware.models import ModelCatalog
from llmware.prompts import Prompt
# all models accessed through the ModelCatalog
models = ModelCatalog().list_all_models()
# to use any model in the ModelCatalog - "load_model" method and pass the model_name parameter
my_model = ModelCatalog().load_model("llmware/bling-phi-3-gguf")
output = my_model.inference("what is the future of AI?", add_context="Here is the article to read")
# to integrate model into a Prompt
prompter = Prompt().load_model("llmware/bling-tiny-llama-v0")
response = prompter.prompt_main("what is the future of AI?", context="Insert Sources of information")1-7B 参数的 RAG 优化模型,专为 RAG 工作流集成而设计,可在本地流畅运行。
• SLIM 系列:针对函数调用和多步骤、多模型代理工作流程进行微调的小型专用模型。
• DRAGON 系列:生产级 RAG 优化的 6-7B 参数模型。
• BLING 系列:基于 CPU 的小型 RAG 优化、遵循指令的 1B-3B 参数模型。
• 行业 BERT 模型:开箱即用的自定义训练句子转换器嵌入模型,针对以下行业进行了微调:保险、合同、资产管理、SEC。
• GGUF 量化:提供许多 SLIM、DRAGON 和 BLING 模型的“gguf”和“工具”版本,并针对 CPU 部署进行了优化。
llmware 旨在使用专为本地和私有部署而设计的小型语言模型实现基于 Agent 和 LLM 的函数调用, 并能够利用开源模型来执行复杂的 RAG 和基于知识的工作流程自动化。
llmware 中的关键元素:
• SLIM 模型 - 18 个函数调用小语言模型,针对特定的提取、分类、生成或摘要活动进行了优化,并生成 python 词典和列表作为输出。
• LLMfx 类 - 支持各种基于代理的流程。
llmware 在默认 ModelCatalog 中支持 30+ 开箱即用的嵌入模型, 并且可以轻松扩展以从 HuggingFace 或 Sentence Transformers 添加其他流行的开源嵌入模型。
要获取当前支持的嵌入模型的列表,请执行以下操作:
from llmware.models import ModelCatalog
embedding_models = ModelCatalog().list_embedding_models()
for i, models in enumerate(embedding_models):
print(f"embedding models: {i} - {models}")支持的热门模型包括:
• Sentence Transformers - all-MiniLM-L6-v2, all-mpnet-base-v2
• Jina AI - jinaai/jina-embeddings-v2-base-en, jinaai/jina-embeddings-v2-small-en
• Nomic - nomic-ai/nomic-embed-text-v1
• Industry BERT - industry-bert-insurance, industry-bert-contracts, industry-bert-asset-management, industry-bert-sec, industry-bert-loans
• OpenAI - text-embedding-ada-002, text-embedding-3-small, text-embedding-3-large
llmware 中的嵌入模型可以直接由 安装,但在大多数情况下, 在创建新嵌入时,嵌入模型的名称将传递给 Library 类中的处理程序。 一旦完成,嵌入模型将作为该库的嵌入记录的一部分捕获到 LibraryCard 上的 Library 元数据中, 因此,通常不需要再次显式使用,例如,
from llmware.library import Library
library = Library().create_new_library("my_library")
# parses the content from the documents in the file path, text chunks and indexes in a text collection database
library.add_files(input_folder_path="/local/path/to/my_files", chunk_size=400, max_chunk_size=600, smart_chunking=1)
# creates embeddings - and keeps synchronized records of which text chunks have been embedded to enable incremental use
library.install_new_embedding(embedding_model_name="jinaai/jina-embeddings-v2-small-en",
vector_db="milvus",
batch_size=100)Library 是 LLMWare 中非结构化信息的主要组织结构。 用户可以创建一个包含所有类型不同内容的大型库, 也可以创建多个库,每个库都包含有关特定主题、项目/案例/交易,甚至不同帐户/用户/部门的特定逻辑信息集合。
每个库都由以下组件组成:
1. 数据库上的集合 - 这是库的核心,通过解析文档创建,然后在文本集合数据库中自动分块和索引。这是检索的基础,也是将用作跟踪可附加到库集合的任意数量的向量嵌入的基础的集合。
2. 文件存档 - 位于 llmware_data 路径中,在 帐户 中,每个库都有一个文件夹结构。库的所有基于文件的工件都组织在这些文件夹中,包括库中添加的所有文件的副本(对于基于检索的应用程序非常有用)、从源文档中提取和索引的图像,以及派生的工件,例如 nlp 和知识图谱和数据集。
3. Library Catalog - 每个 Library 都在 LibraryCatalog 表中注册,并具有唯一的library_card,其中包含 Library 的关键属性和统计信息。
当 Library 对象传递给解析器时,解析器会自动将所有信息路由到 Library 结构中。
该库还提供了方便的方法,可以轻松地在库上安装嵌入,包括跟踪增量进度。
要解析为 Library,有非常有用的便捷方法 add_files,它将调用 Parser, 整理和路由所选文件夹路径中的文件,检查重复文件,执行解析,文本分块和插入数据库,并自动更新所有 Library 状态。
库是执行 Query 时使用的主要索引结构。在构造 Query 对象时传递 library 对象, 然后将仅针对该 Library 中的内容执行所有检索(文本、语义和混合)。
检索和查询是混合了文本、语义、混合、元数据和自定义筛选器的查询库。
retrieval.py 模块实现该类,这是执行搜索和检索的主要方式。 每个对象在构造时都需要在构造函数中将 Library 作为必需参数传递。 Query 对象将针对该 Library 进行操作,并可以访问 Library 的所有特定属性、元数据和方法。
llmware 中的检索利用库抽象作为执行特定查询或检索的主要单元。这提供了拥有多个不同知识库的能力, 这些知识库可能与不同的用例和/或用户、账户和权限保持一致。
# step 1 - load a previously created library
lib = Library().load_library("my_library")
# step 2 - create a query object
q = Query(lib)
# step 3 - run lots of different queries (many other options in the examples)
# basic text query
results1 = q.text_query("text query", result_count=20, exact_mode=False)
# semantic query
results2 = q.semantic_query("semantic query", result_count=10)数据存储易于扩展的数据库选项 - 可以实现从笔记本电脑到并行集群的集成数据存储。
支持了市面上常见的向量库:
from llmware.configs import LLMWareConfig
# to set the collection database - mongo, sqlite, postgres
LLMWareConfig().set_active_db("mongo")
# to set the vector database (or declare when installing)
# --options: milvus, pg_vector (postgres), redis, qdrant, faiss, pinecone, mongo atlas
LLMWareConfig().set_vector_db("milvus")
# for fast start - no installations required
LLMWareConfig().set_active_db("sqlite")
LLMWareConfig().set_vector_db("chromadb") # try also faiss and lancedb
# for single postgres deployment
LLMWareConfig().set_active_db("postgres")
LLMWareConfig().set_vector_db("postgres")Prompt with Sources:将知识检索与 LLM 推理相结合的最简单方法,并提供了几种高级有用的方法, 可以轻松地将检索/查询/解析步骤集成到 Prompt 中,以用作在模型上运行推理的来源。
from llmware.prompts import Prompt
# build a prompt and attach a model
prompter = Prompt().load_model("llmware/bling-tiny-llama-v0")
# add_source_document method: accepts any supported document type, parses the file, and creates text chunks
# if a query is passed, then it will run a quick in-memory filtering search against the text chunks
# the text chunks are packaged into sources with all of the accompanying metadata from the file, and made
# available automatically in batches to be used in prompting -
source = prompter.add_source_document("/folder/to/one/doc/", "filename", query="fast query")
# to run inference with 'prompt with sources' -> source will be automatically added to the prompt
responses = prompter.prompt_with_source("my query")
# depending upon the size of the source (and batching relative to the model context window, there may be more than
# a single inference run, so unpack potentially multiple responses
for i, response in enumerate(responses):
print("response: ", i, response)在本文中,我们简单介绍了 llmware 的基本概念和功能, 这些功能模块涉及到了我们编写 AI 应用程序的核心模块,后面我们一起看下怎么使用 llmware 来实现人工智能应用。
53AI,企业落地大模型首选服务商
产品:场景落地咨询+大模型应用平台+行业解决方案
承诺:免费POC验证,效果达标后再合作。零风险落地应用大模型,已交付160+中大型企业
2025-10-26
关于RAG系统在多轮对话中的问题改写(优化)方法—使用历史记录改写问题
2025-10-26
你的RAG知识库,真的“喂”对数据了吗?拆解dify分段策略,告别无效召回
2025-10-16
基于大模型的智能问答场景解决方案——RAG提升召回率的关键
2025-10-16
用合成数据评测 RAG 系统:一份可直接上手的 DeepEval 实操指南
2025-10-16
2025 年 RAG 最佳 Reranker 模型
2025-10-16
HiRAG问答流程深入分析
2025-10-13
LightRAG × Yuxi-Know——「知识检索 + 知识图谱」实践案例
2025-10-13
PG用户福音|一次性搞定RAG完整数据库套装
2025-09-15
2025-09-02
2025-08-05
2025-08-18
2025-08-25
2025-08-25
2025-08-25
2025-09-03
2025-08-20
2025-09-08
2025-10-04
2025-09-30
2025-09-10
2025-09-10
2025-09-03
2025-08-28
2025-08-25
2025-08-20