定制 halilcosdu/laravel-finetuner 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

halilcosdu/laravel-finetuner

Composer 安装命令:

composer require halilcosdu/laravel-finetuner

包简介

Laravel Fine tuner is a package designed for the Laravel framework that automates the fine-tuning of OpenAI models. It simplifies the process of adjusting model parameters to optimize performance, tailored specifically for Laravel applications. This tool is ideal for developers looking to enhance AI

README 文档

README

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

It simplifies the process of adjusting model parameters to optimize performance, tailored specifically for Laravel applications. This tool is ideal for developers looking to enhance AI capabilities in their projects efficiently, with minimal manual intervention.

Installation

You can install the package via composer:

composer require halilcosdu/laravel-finetuner

You can publish the config file with:

php artisan vendor:publish --tag="finetuner-config"

This is the contents of the published config file:

return [
    'api_key' => env('OPENAI_API_KEY'),
    'organization' => env('OPENAI_ORGANIZATION'),
    'request_timeout' => env('OPENAI_TIMEOUT'),
    'use_storage' => env('FINE_TUNER_USE_STORAGE', false),
    'sleep_seconds' => env('OPENAI_SLEEP_SECONDS'), //Sleep seconds between requests default .1
    'storage' => [
        'disk' => env('FINE_TUNER_STORAGE', 'public'),
    ],

Usage

use HalilCosdu\FineTuner\Facades\FineTuner;

FineTuner::generateExamples($prompt, $temperature = .4, $numberOfExamples = 2): array
FineTuner::upload(string $file): string
FineTuner::fineTune(string $fileId, string $model = 'gpt-3.5-turbo'): string
use HalilCosdu\FineTuner\Facades\FineTuner;

// Generate examples for fine-tuning
$trainingExamples = FineTuner::generateExamples("A versatile AI assistant designed to provide personalized support across all aspects of life, from physical health and mental wellness to emotional well-being, adapting its guidance to the user's unique situation and needs. It offers practical advice, empathetic support, and proactive reminders, all while ensuring privacy and security, and continuously evolving through feedback and research.")
{
  "training_data": [
    {
      "messages": [
        {
          "role": "system",
          "content": "Given your current situation and needs, how can I assist you today?"
        },
        {
          "role": "user",
          "content": "Hey AI, I've been feeling really stressed out lately because of work. Any advice on how I can manage this better?"
        },
        {
          "role": "assistant",
          "content": "I'm really sorry to hear that you're feeling this way, but please know that it's okay to feel stressed. Here are a few suggestions that might help:\n\n1. Mindfulness and Relaxation: Try techniques like deep breathing, meditation, or yoga. They can help you to stay calm and focused.\n\n2. Time Management: Prioritize your tasks and break them down into manageable chunks. Remember, it's okay to say no to tasks that are not a priority.\n\n3. Physical Activity: Regular exercise can help reduce stress levels. Even a short walk can make a difference.\n\n4. Connect with Others: Talk to someone you trust about your stress. It can often help to share what you're experiencing.\n\n5. Professional Help: If your stress continues or leads to feelings of despair, it might be helpful to speak with a mental health professional.\n\nRemember, everyone experiences stress differently and different techniques work for different people. It's important to find what works best for you."
        }
      ]
    }
  ],
  "file_url": null
}
// If the `FINE_TUNER_USE_STORAGE` environment variable is set to `true`, the `file_url` will be returned for the upload function. Alternatively, you can create your own training `.jsonl` file using the `training_data`.

// Upload the training data
$fileId = FineTuner::upload($trainingExamples['file_url'])

// Fine-tune the model
FineTuner::fineTune($fileId, 'gpt-3.5-turbo')

The php artisan laravel-finetuner command is used to interact with the Laravel Finetuner package. This command initiates a process that generates examples.

Here's a detailed explanation of how to use this command:

  1. Open your terminal.

  2. Navigate to your Laravel project directory.

  3. Run the command php artisan laravel-finetuner.

  4. The command will first ask for a Prompt. This is a string that will be used to generate examples for fine-tuning. If you don't provide a prompt, it will use a default one.

  5. Next, it will ask for the Temperature. This is a float value that controls the randomness of the examples generated. A higher value will result in more random examples. If you don't provide a temperature, it will use a default value of .4.

  6. Then, it will ask for the Number of examples. This is an integer that specifies how many examples to generate. If you don't provide a number, it will use a default value of 1.

  7. After you've provided these inputs, the command will ask for your confirmation to continue. If you confirm, it will start generating examples, which may take a while.

  8. Once the examples are generated, they will be uploaded. If there's an error during this process, the command will display an error message.

  9. If everything goes well, the command will display a URL. This URL points to the location where the generated examples were uploaded.

Remember, this command is part of the Laravel Finetuner package, which is designed to automate the fine-tuning of OpenAI models in Laravel applications.

php artisan laravel-finetuner

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.

halilcosdu/laravel-finetuner 适用场景与选型建议

halilcosdu/laravel-finetuner 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 46 次下载、GitHub Stars 达 18, 最近一次更新时间为 2024 年 04 月 19 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「laravel」 「HalilCosdu」 「laravel-finetuner」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 halilcosdu/laravel-finetuner 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 halilcosdu/laravel-finetuner 我们能提供哪些服务?
定制开发 / 二次开发

基于 halilcosdu/laravel-finetuner 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 46
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 18
  • 点击次数: 28
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 18
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-04-19