-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Created sample for 'ApplyWordEmbedding' API. #3142
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
Conversation
Codecov Report
@@ Coverage Diff @@
## master #3142 +/- ##
==========================================
+ Coverage 72.52% 72.53% +0.01%
==========================================
Files 808 808
Lines 144665 144740 +75
Branches 16198 16202 +4
==========================================
+ Hits 104912 104981 +69
- Misses 35342 35348 +6
Partials 4411 4411
|
var predictionEngine = mlContext.Model.CreatePredictionEngine<TextData, TransformedTextData>(textTransformer); | ||
|
||
// Call the prediction API to convert the text into embedding vector. | ||
var data = new TextData() { Text = "This is a greate product. I would like to buy it again." }; |
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.
greate [](start = 58, length = 6)
typo: great #Resolved
{ | ||
|
||
file.WriteLine("This is custom file for 4 words with 3 dimensional word embedding vector. This first line in this file does not confirm to the '<word> <float> <float> <float>' pattern, and is therefore ignored"); | ||
file.WriteLine("greate" + " " + string.Join(" ", 1.0f, 2.0f, 3.0f)); |
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.
greate [](start = 32, length = 6)
typo #Resolved
{ | ||
|
||
file.WriteLine("This is custom file for 4 words with 3 dimensional word embedding vector. This first line in this file does not confirm to the '<word> <float> <float> <float>' pattern, and is therefore ignored"); | ||
file.WriteLine("greate" + " " + string.Join(" ", 1.0f, 2.0f, 3.0f)); |
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.
"greate" + " " + string.Join(" ", 1.0f, 2.0f, 3.0f) [](start = 31, length = 51)
i think it's more readable to write this as "great 1.0 2.0 3.0"
and just add a comment above this line that the following three lines are in format.
It would also be cleaner to turn the line above to comments:
// Write a custom 3-dimensional word embedding vector with 4 words.
// The vectors follow ' ' pattern.
#Resolved
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.
@@ -125,7 +125,7 @@ public static class TextCatalog | |||
/// <example> | |||
/// <format type="text/markdown"> | |||
/// <] |
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.
WordEmbeddingTransform [](start = 101, length = 22)
Should we delete this file WordEmbeddingTransform.cs
which already has a sample for ApplyWordEmbedding
?
Or did we retain this file because its used for some other API sample ? #Closed
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.
|
||
namespace Microsoft.ML.Samples.Dynamic | ||
{ | ||
public static class ApplyCustomWordEmbedding |
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.
ApplyCustomWordEmbedding [](start = 24, length = 24)
is this sample used anywhere ? #Resolved
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.
Look at the overloaded version of ApplyWordEmbedding
method in TextCatalog. It is referenced as an example there similar to other methods.
In reply to: 270986934 [](ancestors = 270986934)
// Write a custom 3-dimensional word embedding model with 4 words. | ||
// Each line follows '<word> <float> <float> <float>' pattern. | ||
// Lines that do not confirm to the pattern are ignored. | ||
var pathToCustomModel = @".\custommodel.txt"; |
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.
@".\custommodel.txt"; [](start = 36, length = 21)
would user reading the documentation get access to this file ? #Resolved
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.
I don't get you properly. This file is created once the sample executes. It is needed to pass on to the ApplyWordEmbedding
method.
In reply to: 270987259 [](ancestors = 270987259)
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.
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.
Thanks! |
Related to #1209.