-
-
Notifications
You must be signed in to change notification settings - Fork 552
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
Add filter when saving dialogue #127
Conversation
namespace BotSharp.Plugin.RoutingSpeeder.Controllers; | ||
|
||
[AllowAnonymous] | ||
public class TrainIntentClassifierController : ControllerBase |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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(); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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>(); |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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(); |
There was a problem hiding this comment.
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(); |
There was a problem hiding this comment.
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")] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/routing-speeder/classifier/train
Add Training Controller, wrap up GetLabel&GetFiles function and Add new model parameters