Skip to content

Add filter when saving dialogue #127

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

evan-cao-wb
Copy link
Contributor

Add Training Controller, wrap up GetLabel&GetFiles function and Add new model parameters

namespace BotSharp.Plugin.RoutingSpeeder.Controllers;

[AllowAnonymous]
public class TrainIntentClassifierController : ControllerBase
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please change name to RoutingSpeederController.

}

[HttpPost("/intent/classifier/training")]
public IActionResult TrainIntentClassifier(TrainingParams trainingParams)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/routingspeeder/classifier/train

@@ -32,6 +32,10 @@ public class IntentClassifier
public bool isModelReady => _isModelReady;
private ClassifierSetting _settings;

private string[] _labels => GetLabels();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GetLabels() will be always trigggered.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could I ask how to fix this?

Copy link
Contributor

@hchen2020 hchen2020 Sep 1, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

private string[] _labels;
public string Labels => GetLabels();

private string[] GetLabels()
{
       if (_labels == null)
       {
           ... 
          _labels = xxxxxx
       }
       return _labels;
}


var labels = GetLabels();
var vector = _services.GetRequiredService<ITextEmbedding>();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we use

var embedding = _services.GetServices<ITextEmbedding>()
    .FirstOrDefault(x => x.GetType().FullName.EndsWith(knowledgeSettings.TextEmbedding));

@@ -10,4 +10,5 @@ public class TrainingParams
public int Epochs { get; set; } = 10;
public int BatchSize { get; set; } = 16;
public float LearningRate { get; set; } = 1.0e-4f;
public bool Reference { get; set; } = false;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo? Inference

}

public string[] GetLabels()
{
var agentService = _services.CreateScope().ServiceProvider.GetRequiredService<IAgentService>();
string rootDirectory = Path.Combine(agentService.GetDataDir(), _settings.MODEL_DIR, _settings.LABEL_FILE_NAME);
var labelText = File.ReadAllLines(rootDirectory);
return labelText.OrderBy(x => x).ToArray();
return labelText.Select(x => x.Replace("intent.", "")).OrderBy(x => x).ToArray();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should keep prefix, the label name will be intent.xxxx.

labelList.AddRange(Enumerable.Repeat(fileName, texts.Count).ToList());
}

// Write label into local file
var uniqueLabelList = labelList.Distinct().OrderBy(x => x).ToArray();
var uniqueLabelList = labelList.Distinct().Select(x => x.Replace("intent.", "")).OrderBy(x => x).ToArray();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please keep intent prefix.

_service = service;
}

[HttpPost("/routingspeeder/classifier/train")]
Copy link
Contributor

@hchen2020 hchen2020 Sep 1, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/routing-speeder/classifier/train

@Oceania2018 Oceania2018 merged commit 55076d5 into SciSharp:master Sep 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants