model.generate()
to model.chat()
. tag:#6Modify RETRIEVAL_MODEL_PATH
in configs/base_config.py to your retrieval model path.
The training of this search engine agent's model is based on the code from the ToolBench repository. If you're interested in the dataset and training code, you can refer to the source repository. ToolBench/Training Retriever
If you don't have a retrieval model, you can download the model from the following links.
Model | Download |
---|---|
MrBun/ToolRetrieval_IR_bert_based_chinese | 🤗HuggingFace / ModelScope |
git clone https://github.com/mMrBun/AIPC.git
conda create -n AIPC python=3.10
conda activate AIPC
cd AIPC
pip install -r requirements.txt
[!NOTE]
Some dependencies in the requirement file cannot be installed on certain operating systems. To avoid installation errors, you can comment out these dependencies.
If you have used langchain, you should be familiar with customizing tools. You can add a new custom tool under the tools
directory, and refer to the existing tools for the specific format.
Of course, to avoid the difficulty of maintaining too many tools, you can create folders to categorize the tools, and the enabled
field in the tools can control whether the tool is enabled or not. No additional configuration is needed; the tools you create will automatically be registered with the existing tools when the program starts.
The principle of tool invocation can refer to OpenAI Function Calling. If the model you are using does not have the capability of calling tools, you can fine-tune the tool invocation commands with LLaMA-Factory.
Certainly, if your API doesn't involve proprietary terms or specific semantic content, you can use an open-source embedding model for semantic query retrieval of tools. Training an embedding model is to make it perform better in downstream tasks.
python api_demo.py \
--model_name_or_path /path/to/your/model \
--template default \
--infer_backend vllm
[!NOTE]
VLLM is currently not available on Windows; the infer_backend can be omitted or changed to huggingface
The template can refer to the configuration in the model list
The code in this repository is inspired by the following open-source projects. Thanks to the work of these open-source projects.