Language-only Full-Parameter Finetuning#
Single-turn LLaMA2-7B on Alpaca#
Script:
Data:
Model Release:
Host Local Demo:
torchrun --nproc-per-node=1 demos/single_turn.py \
--llama_config /path/to/params.json --tokenizer_path /path/to/tokenizer.model \
--pretrained_path /path/to/alpaca_finetuned
Example:
Instruction:
Write an introduction for the github repository “LLaMA2-Accesory: An Open-source Toolkit for LLM Development”.
Answer:
Hello and welcome to the LLaMA2-Accesory GitHub repository! This is an open-source toolkit designed specifically for the development of LLM (Language Modeling) applications. Built on top of the powerful LLaMA2 library, this toolkit provides a user-friendly interface and a set of robust utilities to help you build and train your own LLM models with ease. Whether you are a seasoned AI developer or just getting started with LLaMA2, this toolkit has got you covered with its robust features and extensive documentation. Let’s get started on building your LLaMA2-based application today!
Single-turn InternLM-7B on Alpaca#
Script:
Data:
Model Release:
Host Local Demo:
torchrun --nproc-per-node=1 demos/single_turn.py \
--llama_config /path/to/params.json --tokenizer_path /path/to/tokenizer.model \
--pretrained_path /path/to/alpaca_finetuned
Example:
Human: 生成一篇关于人工智能未来发展趋势的文章
Assistant: 人工智能的未来发展趋势
人工智能(AI)技术在过去几十年中取得了长足的进步,它正在改变我们的生活方式和商业运作方式。未来,人工智能将如何发展?本文将探讨人工智能的未来发展趋势。
首先,人工智能将更加智能化。随着机器学习和深度学习技术的不断发展,人工智能将能够更好地理解和处理复杂数据,从而做出更加智能的决策。例如,在医疗领域,人工智能将能够更好地诊断疾病,为患者提供更精准的治疗方案。在金融领域,人工智能将能够更好地预测市场走势,为投资者提供更精准的投资建议。
其次,人工智能将更加人性化。随着自然语言处理技术的不断发展,人工智能将能够更好地与人类进行交流和沟通。例如,智能语音助手将能够更好地理解人类的语言,为人类提供更加人性化的服务。此外,人工智能也将更加注重隐私保护,为人类提供更加安全、可靠的个人信息保护措施。
最后,人工智能将更加普及。随着人工智能技术的不断发展,它将逐渐渗透到人们的日常生活中,为人们提供更加便捷、高效的智能化服务。例如,智能家居系统将能够更好地控制家庭中的各种设备,为人们提供更加舒适、便捷的生活环境。
Single-turn LLaMA2-7B on Gorilla#
Script:
Data:
Here we take tensorflowhub as example, other subset can be handled in similar way:
Download data from 💾here
Run tools/data_conversion/to_alpaca/gorilla.py with specified
--data_path
to reformat original dataMake sure gorilla.yaml is correctly specified to formatted data file
Model Release:
Host Local Demo:
torchrun --nproc-per-node=1 demos/single_turn.py \
--llama_config /path/to/params.json --tokenizer_path /path/to/tokenizer.model \
--pretrained_path /path/to/gorilla_finetuned
Accuracies:
Tuning scripts used here can be found in: Zero-init Attenion(i.e. LLaMA-adapter), Bias-norm Tuning, LoRA + Bias-norm.
Methods (TensorFlow Hub) |
Overall ↑ |
Hallu ↓ |
---|---|---|
Official |
83.79 |
5.40 |
Full finetune |
88.84 |
0.14 |
Zero-init Attention |
84.97 |
1.04 |
Bias-norm Tuning |
80.36 |
7.29 |
LoRA + Bias-norm |
87.95 |
2.38 |
Example:
Instruction:
I am working on a project where I need to cluster similar images of street art. How can I get the relevant feature vectors from these images for clustering?
Answer:
<<<domain>>>: Image feature vector,
<<<api_call>>>: hub.KerasLayer(‘https://tfhub.dev/google/imagenet/mobilenet_v2_100_224/feature_vector/4’),
<<<api_provider>>>: TensorFlow Hub,
<<<explanation>>>: This API call loads a pretrained MobileNetV2 model from TensorFlow Hub, which has been trained on the ImageNet dataset. This model is used for extracting feature vectors from images. You can feed your street art images into this model to obtain feature vectors, which can then be used for clustering.
<<<code>>>:
import tensorflow as tf
import tensorflow_hub as hub
model = tf.keras.Sequential([
hub.KerasLayer('https://tfhub.dev/google/imagenet/mobilenet_v2_100_224/feature_vector/4',
input_shape=(224, 224, 3),
trainable=False)
])
image = tf.keras.preprocessing.image.load_img('path/to/image.jpg', target_size=(224, 224))
image_array = tf.keras.preprocessing.image.img_to_array(image)
image_array = tf.expand_dims(image_array, 0)
features = model.predict(image_array)
Multi-turn LLaMA2-7B on LIMA#
Script:
Data:
Model Release:
Host Local Demo:
python demos/multi_turn.py \
--llama_config /path/to/params.json --tokenizer_path /path/to/tokenizer.model \
--pretrained_path /path/to/lima_finetuned
Example:
A chat between a curious human and an artificial intelligence assistant. The assistant gives helpful, detailed, and polite answers to the human’s questions.
Human: Write about a time when you learned an important lesson about communication.
Assistant: I was working as a customer service representative for a major telecommunications company. It was a pretty typical day, lots of customers with different issues. One particular call stuck with me though. An elderly gentleman was having trouble with his internet. He was having a hard time hearing me and I could tell he was getting frustrated. After troubleshooting for a bit, I realized that the issue wasn’t on my end, but rather the gentleman’s. His hearing aid was malfunctioning and he wasn’t able to hear me properly. I took a few moments to explain this to him and let him know that I would be happy to transfer him to our tech support team so that they could help him with his hearing aid. The lesson I learned from this experience is that sometimes, the issue isn’t on the other end, but rather on your own. You have to be willing to step back, take a breath, and assess the situation before jumping to conclusions.
Human: I like the story, but could you add some tips on how to effectively communicate with colleagues in a professional setting?
Assistant: Sure, here are some tips on how to effectively communicate with colleagues in a professional setting:
Be clear and concise in your communication. Get to the point quickly and avoid using jargon or industry buzzwords that your colleagues may not understand.
Listen actively when others are speaking. Nod your head, ask clarifying questions, and avoid interrupting.
Respect the time and attention of your colleagues. Don’t monopolize conversations or meetings, and be mindful of the amount of time you’re taking away from others.
Be open and honest in your communication. Don’t withhold information or try to manipulate others.
Follow up on communication. Whether it’s an email you sent or a meeting you had, make sure that everyone is on the same page and that any necessary actions are being taken.
By following these tips, you can ensure that your communication with colleagues is effective and professional.
Human: Could you expand on the tip about respecting the time and attention of colleagues?
Assistant: Sure, here is some more information on the tip about respecting the time and attention of colleagues.
Don’t monopolize conversations or meetings. If someone else has something to contribute, let them. If you find that you’re dominating the conversation, take a step back and let others speak.
Be mindful of the amount of time you’re taking away from others. If you’re in a meeting or working on a project with a deadline, be aware of how much time you’re using and how much others are using. Don’t take up more time than necessary.
Avoid multitasking. It may seem like you’re being efficient by doing multiple things at once, but in reality, you’re probably not giving your full attention to any one thing. When communicating with colleagues, give them your undivided attention.
Be considerate of others’ schedules. If you know that someone has a tight deadline or is leaving for vacation soon, don’t schedule a meeting with them during that time.
By following these guidelines, you can ensure that your communication with colleagues is respectful of their time and attention.
Single-turn LLaMA2-7B on WizardLM#
Script:
Data:
Model Release:
Host Local Demo:
python demos/multi_turn.py \
--llama_config /path/to/params.json --tokenizer_path /path/to/tokenizer.model \
--pretrained_path /path/to/wizardLM_finetuned
Example:
A chat between a curious human and an artificial intelligence assistant. The assistant gives helpful, detailed, and polite answers to the human’s questions.
Human: Write a quicksort code. You need to use C++ as the programming language and generate a function called quicksort.
Assistant: Here’s a quicksort implementation in C++:
#include <iostream>
#include <algorithm>
using namespace std;
void quicksort(int arr[], int left, int right) {
int i = left, j = right;
int pivot = arr[(left + right) / 2];
while (i <= j) {
while (arr[i] < pivot) {
i++;
}
while (arr[j] > pivot) {
j--;
}
if (i <= j) {
swap(arr[i], arr[j]);
i++;
j--;
}
}
quicksort(arr, left, j);
quicksort(arr, i, right);
}
int main() {
int arr[] = { 3, 1, 4, 1, 5, 9, 2, 6, 5, 3 };
int n = sizeof(arr) / sizeof(arr[0]);
cout << "Original array: ";
for (int i = 0; i < n; i++) {
cout << arr[i] << " ";
}
cout << endl;
quicksort(arr, 0, n - 1);
cout << "Sorted array: ";
for (int i = 0; i < n; i++) {
cout << arr[i] << " ";
}
cout << endl;
return 0;
}
The quicksort function takes in an array arr, as well as the left and right indices of the subarray to be sorted. It first finds a pivot element, which is the middle element of the subarray. It then rearranges the elements in the subarray such that all elements less than the pivot are to its left, and all elements greater than the pivot are to its right. It recursively calls itself on the left and right subarrays until the entire array is sorted.
In the main function, we define an unsorted array and call quicksort on it. We then print out the sorted array to verify that the sorting was successful.
Single-turn CodeLLaMA-7B on WizardCode#
Script:
Data:
Model Release:
Host Local Demo:
python demos/multi_turn.py \
--llama_config /path/to/params.json --tokenizer_path /path/to/tokenizer.model \
--pretrained_path /path/to/wizardCode_finetuned
Attention
The Code LLaMA series has different params.json
and tokenizer.model
files from LLaMA and LLaMA2. Make sure to use the Code-LLaMA version of these files.
More use cases coming soon…