Code
Hub
Workspaces
Following
Trending
Connect
MCP
copy
Create free account
hub
/
github.com/buckhx/gobert
/ functions
Functions
88 in github.com/buckhx/gobert
⨍
Functions
88
◇
Types & classes
23
↓ 7 callers
Function
exit
(msgs ...interface{})
examples/semantic-search/main.go:90
↓ 6 callers
Method
Value
()
model/bert.go:35
↓ 5 callers
Method
PredictValues
PredictValues will run the BERT model on the provided texts. The returned values are in the same order as the provided texts.
model/bert.go:95
↓ 5 callers
Method
println
(msg ...interface{})
model/bert.go:117
↓ 4 callers
Method
GetID
GetID will return the ID of the token in the vocab. Will be negative if it doesn't exists
tokenize/vocab/vocab.go:59
↓ 4 callers
Method
Tokenize
(text string)
tokenize/tokenizer.go:12
↓ 4 callers
Function
tokenizeWhitespace
tokenizeWhitespace splits text into tokeens by whitespace, per python semantics empty strings are not included
tokenize/basic.go:86
↓ 3 callers
Method
Int32
Int32 int32 representation of an ID
tokenize/vocab/vocab.go:17
↓ 2 callers
Method
Count
Count will return the number of tokens in the feature by counting the mask bits
tokenize/feature.go:27
↓ 2 callers
Method
Feature
Feature will create a single feature from the factory ID creation is thread safe and incremental
tokenize/feature.go:47
↓ 2 callers
Method
Features
Features will tokenize a text
model/bert.go:89
↓ 2 callers
Method
LongestSubstring
LongestSubstring returns the longest token that is a substring of the token
tokenize/vocab/vocab.go:95
↓ 2 callers
Function
NewBert
NewBert will create a new default BERT model from the exported model and vocab. Generally used for producing embeddings
model/bert.go:52
↓ 2 callers
Function
NewTokenizer
NewTokenizer returns a new FullTokenizer Use Option array to modify default behavior
tokenize/tokenizer.go:23
↓ 2 callers
Function
download
(model, output_path, force=False, keep=False)
export/download_pretrained.py:31
↓ 2 callers
Function
export
(model_path, export_path, transfer_func, method_name="bert/tuned/predict", tags=["bert-tuned"],
export/util.py:7
↓ 2 callers
Function
isChinese
IsChinese validates that rune c is in the CJK range according to BERT spec
tokenize/unicode.go:65
↓ 2 callers
Function
isControl
IsControl checks wher rune c is a BERT control character
tokenize/unicode.go:47
↓ 2 callers
Function
isPunctuation
IsPunctuation checks wher rune c is a BERT punctuation character
tokenize/unicode.go:60
↓ 2 callers
Function
isWhitespace
IsWhitespace checks whether rune c is a BERT whitespace character
tokenize/unicode.go:32
↓ 2 callers
Function
meanPool
TODO extract this into a reusable package
examples/semantic-search/engine.go:104
↓ 2 callers
Function
padChinese
padChinese will add space padding around all CJK chars This implementation matches BasicTokenizer._tokenize_chinese_chars
tokenize/basic.go:100
↓ 2 callers
Function
sequenceFeature
SequenceFeature will take a sequence string and build features for the model from it
tokenize/feature.go:67
↓ 2 callers
Function
truncate
truncate uses heuristic of trimming seq with longest len until seqlen satisfied
tokenize/feature.go:106
↓ 1 callers
Method
Add
Add will add an item to the vocabulary, is not thread-safe
tokenize/vocab/vocab.go:54
↓ 1 callers
Method
Features
Features will create multiple features with incremental IDs
tokenize/feature.go:57
↓ 1 callers
Function
NewBasic
NewBasic returns a basic tokenizer. Method is supplied to match constructor of other tokenizers
tokenize/basic.go:18
↓ 1 callers
Function
NewWordpiece
NewWordpiece returns a WordpieceTokenizer with the default settings. Generally should be used in a FullTokenizer
tokenize/wordpiece.go:25
↓ 1 callers
Method
Predict
(InputFunc)
model/estimator/estimator.go:28
↓ 1 callers
Method
Size
* // GetToken will get a token by the ID, returns the mepty string if ID does not exist func (v Dict) GetToken(id ID) token { for k, v := range v.tok
tokenize/vocab/vocab.go:90
↓ 1 callers
Method
Tokenize
Tokenize will segment a texxt into individual tokens. Follows algorithm from ref-imp Clean, PadChinese, Whitespace Split, Lower?, SplitPunc, Whitespac
tokenize/basic.go:24
↓ 1 callers
Method
Tokenize
Tokenize will segment the text into subword tokens from the supplied vocabulary NOTE: This implementation does not EXACTLY match the ref-impl and beha
tokenize/wordpiece.go:36
↓ 1 callers
Method
Vocab
()
tokenize/vocab/vocab.go:10
↓ 1 callers
Function
WithModelFunc
WithModelFunc applies the given model func, used when outputs do not match the default
model/option.go:36
↓ 1 callers
Function
WithSeqLen
WithSeqLen applies the seqlen, should match max_seq_len from trained model
model/option.go:20
↓ 1 callers
Function
_unzip
unzips archive and flattens directory structure
export/download_pretrained.py:59
↓ 1 callers
Function
clean
(text string)
tokenize/basic.go:41
↓ 1 callers
Function
cosSim
(x, y mat.Vector)
examples/go-similarity/main.go:61
↓ 1 callers
Function
cosSim
(x, y mat.Vector)
examples/semantic-search/engine.go:117
↓ 1 callers
Function
export_classifier
(args)
export/export_classifier.py:29
↓ 1 callers
Function
export_embedding
(args)
export/export_embedding.py:28
↓ 1 callers
Method
loadCSV
(csvPath string, d rune)
examples/semantic-search/engine.go:33
↓ 1 callers
Function
newEngine
(modelPath string, seqlen int32)
examples/semantic-search/engine.go:21
↓ 1 callers
Function
pool
(toks [][]float32)
examples/go-similarity/main.go:48
↓ 1 callers
Function
readCSV
readCSV will read a CSV file and parse the records into maps keyed by column headers, requires a column with the header "text"
examples/semantic-search/csv.go:16
↓ 1 callers
Method
search
(text string)
examples/semantic-search/engine.go:85
↓ 1 callers
Function
splitPunc
(text string)
tokenize/basic.go:66
↓ 1 callers
Function
stripAccents
(text string)
tokenize/basic.go:55
Function
FromFile
FromFile will read a newline delimited file into a Dict
tokenize/vocab/vocab.go:28
Function
New
New iwll return a a covab dict from the given tokens, IDs will match index
tokenize/vocab/vocab.go:45
Function
NewBertClassifier
NewBertClassifier returns a model configured for classification after being fine-tuned with run_classification.py
model/classifier.go:15
Function
NewEmbeddings
NewEmbeddings returns a pre-trained model for text embeddings
model/embedding.go:14
Function
NewPredictor
NewPredictor creates a new Predictor in lieu of a full estimator
model/estimator/predict.go:16
Method
Predict
Predictor will apply fn to the estimator model
model/estimator/predict.go:26
Function
Print
Print is a utility for printing the operations in a saved model
model/bert.go:124
Method
SetMaxWordChars
SetMaxWordChars will set the max chars for a word to be tokenized, generally this should be congfigured through the FullTokenizer
tokenize/wordpiece.go:60
Method
SetUnknownToken
SetUnknownToken will set the , generally this should be congfigured through the FullTokenizer
tokenize/wordpiece.go:65
Function
TestBasic
(t *testing.T)
tokenize/tokenizer_test.go:11
Function
TestDictLongestSubstring
(t *testing.T)
tokenize/vocab/vocab_test.go:20
Function
TestFeatureCount
(t *testing.T)
tokenize/feature_test.go:10
Function
TestNewDict
(t *testing.T)
tokenize/vocab/vocab_test.go:9
Function
TestTestBasicLower
(t *testing.T)
tokenize/basic_test.go:8
Function
TestWordpiece
(t *testing.T)
tokenize/tokenizer_test.go:32
Function
Test_isChinese
***** New Tests *****/
tokenize/unicode_test.go:66
Function
Test_isControl
(t *testing.T)
tokenize/unicode_test.go:28
Function
Test_isPunctuation
(t *testing.T)
tokenize/unicode_test.go:46
Function
Test_isWhitespace
***** Ported Tests *****/
tokenize/unicode_test.go:9
Function
Test_padChinese
(t *testing.T)
tokenize/basic_test.go:48
Function
Test_sequenceFeature
(t *testing.T)
tokenize/feature_test.go:30
Function
Test_sequenceTruncate
(t *testing.T)
tokenize/feature_test.go:54
Function
Test_tokenizeWhitespace
(t *testing.T)
tokenize/basic_test.go:25
Method
Tokenize
Tokenize will tokenize the input text First basic is applited, then wordpiece on the tokens froms basic
tokenize/full.go:13
Method
Vocab
Vocab returns the vocub used for this tokenizer
tokenize/full.go:22
Function
WithFeatureFactory
WithFeatureFactory replaces the default feature factory
model/option.go:28
Function
WithInputFunc
WithInputFunc updates the input func, used if input tensors vary from defaults
model/option.go:44
Function
WithLower
WithLower will lowercase all input if set to true, or skip lowering if false NOTE: kink from reference implementation is that lowering also strips acc
tokenize/tokenizer.go:40
Function
WithMaxChars
WithMaxChars sets the maximum len of a token to be tokenized, if longer will be labeled as unknown
tokenize/tokenizer.go:56
Function
WithTokenizer
WithTokenizer applies the given tokenizer to the model
model/option.go:12
Function
WithUnknownToken
WithUnknownToken will alter the unkown token from default [UNK]
tokenize/tokenizer.go:48
Function
init
()
examples/semantic-search/main.go:27
Function
main
()
examples/go-similarity/main.go:12
Function
main
* 1. Download base model 2. Fine tune w/ run_classifier 3. export_classifier $MODEL_DIR $EXPORT_DIR 2 4. MODEL_PATH=$EXPORT_DIR go run main.go */
examples/classifier/main.go:18
Function
main
()
examples/raw-model/main.go:12
Function
main
()
examples/embedding/main.go:10
Function
main
()
examples/semantic-search/main.go:52
Function
tensors
(fs ...tokenize.Feature)
model/bert.go:146
Function
transfer
()
export/export_classifier.py:36
Function
transfer
()
export/export_embedding.py:39