mirror of
https://github.com/MervinPraison/PraisonAI.git
synced 2026-11-07 17:33:33 -10:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b8574f78e2 | ||
|
|
e631774a0f | ||
|
|
df735aa748 | ||
|
|
3bdf5b6c65 | ||
|
|
361fa67108 | ||
|
|
c5abcf362a | ||
|
|
7ed2d99a11 | ||
|
|
81307da7c8 | ||
|
|
fb75153b5c | ||
|
|
cddcfcf170 | ||
|
|
398b0473e0 | ||
|
|
c5d260782a |
No files matched your search
+1
-1
@@ -1,6 +1,6 @@
|
||||
FROM python:3.11-slim
|
||||
WORKDIR /app
|
||||
COPY . .
|
||||
RUN pip install flask praisonai==2.0.69 gunicorn markdown
|
||||
RUN pip install flask praisonai==2.0.74 gunicorn markdown
|
||||
EXPOSE 8080
|
||||
CMD ["gunicorn", "-b", "0.0.0.0:8080", "api:app"]
|
||||
@@ -110,7 +110,7 @@ Loads environment variables from .env file or system and sets them.</p>
|
||||
file.write("FROM python:3.11-slim\n")
|
||||
file.write("WORKDIR /app\n")
|
||||
file.write("COPY . .\n")
|
||||
file.write("RUN pip install flask praisonai==2.0.69 gunicorn markdown\n")
|
||||
file.write("RUN pip install flask praisonai==2.0.74 gunicorn markdown\n")
|
||||
file.write("EXPOSE 8080\n")
|
||||
file.write('CMD ["gunicorn", "-b", "0.0.0.0:8080", "api:app"]\n')
|
||||
|
||||
|
||||
+22
-2
@@ -28,8 +28,11 @@ praisonai train init
|
||||
|
||||
## Required
|
||||
|
||||
1. HF_TOKEN
|
||||
2. Below config.yaml file in the same directory
|
||||
1. Huggingface token
|
||||
2. Base model to train on (e.g. unsloth/Meta-Llama-3.1-8B-Instruct-bnb-4bit)
|
||||
3. Dataset to train on (e.g. yahma/alpaca-cleaned)
|
||||
4. Huggingface model name to upload to (e.g. mervinpraison/llama3.1-instruct) (Optional)
|
||||
5. Ollama model name to upload to (e.g. mervinpraison/llama3.1-instruct) (Optional)
|
||||
|
||||
## To upload to ollama.com (Linux)
|
||||
|
||||
@@ -119,4 +122,21 @@ quantization_method:
|
||||
|
||||
```bash
|
||||
praisonai train
|
||||
```
|
||||
|
||||
## wandb
|
||||
|
||||
```bash
|
||||
wandb login
|
||||
```
|
||||
|
||||
<Note>
|
||||
Get the key from [here](https://wandb.ai/site/login)
|
||||
</Note>
|
||||
|
||||
```bash
|
||||
export PRAISON_WANDB=True
|
||||
export WANDB_LOG_MODEL=checkpoint
|
||||
export WANDB_PROJECT=praisonai-test
|
||||
export PRAISON_WANDB_RUN_NAME=praisonai-train
|
||||
```
|
||||
+1
-1
@@ -3,7 +3,7 @@ class Praisonai < Formula
|
||||
|
||||
desc "AI tools for various AI applications"
|
||||
homepage "https://github.com/MervinPraison/PraisonAI"
|
||||
url "https://github.com/MervinPraison/PraisonAI/archive/refs/tags/2.0.69.tar.gz"
|
||||
url "https://github.com/MervinPraison/PraisonAI/archive/refs/tags/2.0.74.tar.gz"
|
||||
sha256 "1828fb9227d10f991522c3f24f061943a254b667196b40b1a3e4a54a8d30ce32" # Replace with actual SHA256 checksum
|
||||
license "MIT"
|
||||
|
||||
|
||||
+15
-2
@@ -189,8 +189,7 @@ class PraisonAI:
|
||||
package_root = os.path.dirname(os.path.abspath(__file__))
|
||||
config_yaml_destination = os.path.join(os.getcwd(), 'config.yaml')
|
||||
|
||||
# Create config.yaml only if it doesn't exist or --model or --dataset is provided
|
||||
if not os.path.exists(config_yaml_destination) or args.model or args.dataset:
|
||||
if not os.path.exists(config_yaml_destination):
|
||||
config = generate_config(
|
||||
model_name=args.model,
|
||||
hf_model_name=args.hf,
|
||||
@@ -201,6 +200,20 @@ class PraisonAI:
|
||||
)
|
||||
with open('config.yaml', 'w') as f:
|
||||
yaml.dump(config, f, default_flow_style=False, indent=2)
|
||||
elif args.model or args.hf or args.ollama or (args.dataset and args.dataset != "yahma/alpaca-cleaned"):
|
||||
config = generate_config(
|
||||
model_name=args.model,
|
||||
hf_model_name=args.hf,
|
||||
ollama_model_name=args.ollama,
|
||||
dataset=[{
|
||||
"name": args.dataset
|
||||
}]
|
||||
)
|
||||
with open('config.yaml', 'w') as f:
|
||||
yaml.dump(config, f, default_flow_style=False, indent=2)
|
||||
else:
|
||||
with open(config_yaml_destination, 'r') as f:
|
||||
config = yaml.safe_load(f)
|
||||
|
||||
# Overwrite huggingface_save and ollama_save if --hf or --ollama are provided
|
||||
if args.hf:
|
||||
|
||||
+1
-1
@@ -56,7 +56,7 @@ class CloudDeployer:
|
||||
file.write("FROM python:3.11-slim\n")
|
||||
file.write("WORKDIR /app\n")
|
||||
file.write("COPY . .\n")
|
||||
file.write("RUN pip install flask praisonai==2.0.69 gunicorn markdown\n")
|
||||
file.write("RUN pip install flask praisonai==2.0.74 gunicorn markdown\n")
|
||||
file.write("EXPOSE 8080\n")
|
||||
file.write('CMD ["gunicorn", "-b", "0.0.0.0:8080", "api:app"]\n')
|
||||
|
||||
|
||||
@@ -100,6 +100,6 @@ $PIP_FULL_PATH install "unsloth[colab-new] @ git+https://github.com/unslothai/un
|
||||
$PIP_FULL_PATH install --no-deps "trl<0.9.0" peft accelerate bitsandbytes
|
||||
$PIP_FULL_PATH install unsloth_zoo
|
||||
$PIP_FULL_PATH install cut_cross_entropy
|
||||
$PIP_FULL_PATH install sentencepiece protobuf datasets huggingface_hub hf_transfer
|
||||
$PIP_FULL_PATH install sentencepiece protobuf datasets huggingface_hub hf_transfer wandb
|
||||
|
||||
echo "Setup completed successfully!"
|
||||
+33
-27
@@ -1,7 +1,7 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
This script finetunes a model using Unsloth’s fast training framework.
|
||||
This script finetunes a model using Unsloth's fast training framework.
|
||||
It supports both ShareGPT and Alpaca‑style datasets by converting raw conversation
|
||||
data into plain-text prompts using a chat template, then pre‑tokenizing the prompts.
|
||||
Extra debug logging is added to help trace the root cause of errors.
|
||||
@@ -27,7 +27,7 @@ from functools import partial
|
||||
#####################################
|
||||
def formatting_prompts_func(examples, tokenizer):
|
||||
"""
|
||||
Converts each example’s conversation into a single plain-text prompt.
|
||||
Converts each example's conversation into a single plain-text prompt.
|
||||
If the example has a "conversations" field, process it as ShareGPT-style.
|
||||
Otherwise, assume Alpaca-style data with "instruction", "input", and "output" fields.
|
||||
"""
|
||||
@@ -216,25 +216,29 @@ class TrainModel:
|
||||
raw_dataset = self.load_datasets()
|
||||
tokenized_dataset = self.tokenize_dataset(raw_dataset)
|
||||
print("DEBUG: Dataset tokenization complete.")
|
||||
training_args = TrainingArguments(
|
||||
per_device_train_batch_size=2,
|
||||
gradient_accumulation_steps=4,
|
||||
warmup_steps=5,
|
||||
max_steps=60,
|
||||
learning_rate=2e-4,
|
||||
fp16=not is_bfloat16_supported(),
|
||||
bf16=is_bfloat16_supported(),
|
||||
logging_steps=1,
|
||||
optim="adamw_8bit",
|
||||
weight_decay=0.01,
|
||||
lr_scheduler_type="linear",
|
||||
seed=3407,
|
||||
output_dir="outputs",
|
||||
report_to="none" if not os.getenv("PRAISON_WANDB") else "wandb",
|
||||
save_steps=100 if os.getenv("PRAISON_WANDB") else None,
|
||||
run_name=os.getenv("PRAISON_WANDB_RUN_NAME", "praisonai-train") if os.getenv("PRAISON_WANDB") else None,
|
||||
remove_unused_columns=False,
|
||||
)
|
||||
# Build the training arguments parameters dynamically
|
||||
ta_params = {
|
||||
"per_device_train_batch_size": self.config.get("per_device_train_batch_size", 2),
|
||||
"gradient_accumulation_steps": self.config.get("gradient_accumulation_steps", 2),
|
||||
"warmup_steps": self.config.get("warmup_steps", 50),
|
||||
"max_steps": self.config.get("max_steps", 2800),
|
||||
"learning_rate": self.config.get("learning_rate", 2e-4),
|
||||
"fp16": self.config.get("fp16", not is_bfloat16_supported()),
|
||||
"bf16": self.config.get("bf16", is_bfloat16_supported()),
|
||||
"logging_steps": self.config.get("logging_steps", 15),
|
||||
"optim": self.config.get("optim", "adamw_8bit"),
|
||||
"weight_decay": self.config.get("weight_decay", 0.01),
|
||||
"lr_scheduler_type": self.config.get("lr_scheduler_type", "linear"),
|
||||
"seed": self.config.get("seed", 3407),
|
||||
"output_dir": self.config.get("output_dir", "outputs"),
|
||||
"report_to": "none" if not os.getenv("PRAISON_WANDB") else "wandb",
|
||||
"remove_unused_columns": self.config.get("remove_unused_columns", False)
|
||||
}
|
||||
if os.getenv("PRAISON_WANDB"):
|
||||
ta_params["save_steps"] = self.config.get("save_steps", 100)
|
||||
ta_params["run_name"] = os.getenv("PRAISON_WANDB_RUN_NAME", "praisonai-train")
|
||||
|
||||
training_args = TrainingArguments(**ta_params)
|
||||
# Since the dataset is pre-tokenized, we supply a dummy dataset_text_field.
|
||||
trainer = SFTTrainer(
|
||||
model=self.model,
|
||||
@@ -425,12 +429,16 @@ class TrainModel:
|
||||
"template": """{{- if .System }}{{ .System }}{{ end }}
|
||||
{{- range $i, $_ := .Messages }}
|
||||
{{- $last := eq (len (slice $.Messages $i)) 1}}
|
||||
{{- if eq .Role "user" }}<|User|>{{ .Content }}
|
||||
{{- else if eq .Role "assistant" }}<|Assistant|>{{ .Content }}{{- if not $last }}<|end▁of▁sentence|>{{- end }}
|
||||
{{- if eq .Role "user" }}
|
||||
{{ .Content }}
|
||||
{{- else if eq .Role "assistant" }}
|
||||
{{ .Content }}{{- if not $last }}
|
||||
{{- end }}
|
||||
{{- if and $last (ne .Role "assistant") }}<|Assistant|>{{- end }}
|
||||
{{- end }}
|
||||
{{- if and $last (ne .Role "assistant") }}
|
||||
{{ end }}
|
||||
{{- end }}""",
|
||||
"stop_tokens": ["<|begin▁of▁sentence|>", "<|end▁of▁sentence|>", "<|User|>", "<|Assistant|>"]
|
||||
"stop_tokens": ["", "", "", ""]
|
||||
},
|
||||
"llava": {
|
||||
"template": """{{- if .Suffix }}<|fim_prefix|>{{ .Prompt }}<|fim_suffix|>{{ .Suffix }}<|fim_middle|>
|
||||
@@ -513,8 +521,6 @@ class TrainModel:
|
||||
{system_line}{num_ctx_line}{stop_params}
|
||||
"""
|
||||
|
||||
|
||||
|
||||
def create_and_push_ollama_model(self):
|
||||
modelfile_content = self.prepare_modelfile_content()
|
||||
with open("Modelfile", "w") as file:
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
[project]
|
||||
name = "PraisonAI"
|
||||
version = "2.0.69"
|
||||
version = "2.0.74"
|
||||
description = "PraisonAI is an AI Agents Framework with Self Reflection. PraisonAI application combines PraisonAI Agents, AutoGen, and CrewAI into a low-code solution for building and managing multi-agent LLM systems, focusing on simplicity, customisation, and efficient human-agent collaboration."
|
||||
readme = "README.md"
|
||||
license = ""
|
||||
@@ -84,7 +84,7 @@ autogen = ["pyautogen>=0.2.19", "praisonai-tools>=0.0.7", "crewai"]
|
||||
|
||||
[tool.poetry]
|
||||
name = "PraisonAI"
|
||||
version = "2.0.69"
|
||||
version = "2.0.74"
|
||||
description = "PraisonAI is an AI Agents Framework with Self Reflection. PraisonAI application combines PraisonAI Agents, AutoGen, and CrewAI into a low-code solution for building and managing multi-agent LLM systems, focusing on simplicity, customisation, and efficient human–agent collaboration."
|
||||
authors = ["Mervin Praison"]
|
||||
license = ""
|
||||
|
||||
Reference in new issue
Block a user