PHP Classes

File: backend/runTrainModel.php

Recommend this page to a friend!
  Classes of Rodrigo Faustino   Modelo LLM PHP   backend/runTrainModel.php   Download  
File: backend/runTrainModel.php
Role: Example script
Content type: text/plain
Description: Example script
Class: Modelo LLM PHP
Large language model to implement a chat bot
Author: By
Last change:
Date: Yesterday
Size: 600 bytes
 

Contents

Class file image Download
<?php
ini_set
('memory_limit', '14096M');

require
'vendor/autoload.php';

use
Chat\X\Utils\NextWordPredictor;

$ngramPath = 'ngrams.json';
$modelDir = 'model';
$modelPath = $modelDir . '/naive_bayes_model.phpml';
$vectorizerPath = $modelDir . '/vectorizer.phpml';
$featureSelectorPath = $modelDir . '/feature_selector.phpml';

// Cria a pasta 'model' se não existir (já tratado na classe)
if (!is_dir($modelDir)) {
   
mkdir($modelDir, 0755, true);
}

$predictor = new NextWordPredictor($ngramPath);
$predictor->train();
$predictor->saveModel($modelPath, $vectorizerPath, $featureSelectorPath);
?>