-
-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feat: Tokenize String, Test / Build cleanup (#164)
Co-authored-by: Ettore Di Giacinto <mudler@users.noreply.github.com>
- Loading branch information
1 parent
18f25c2
commit f4f03cc
Showing
6 changed files
with
122 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package llama_test | ||
|
||
import ( | ||
"os" | ||
|
||
. "github.com/go-skynet/go-llama.cpp" | ||
. "github.com/onsi/ginkgo/v2" | ||
. "github.com/onsi/gomega" | ||
) | ||
|
||
var _ = Describe("LLama binding", func() { | ||
testModelPath := os.Getenv("TEST_MODEL") | ||
|
||
Context("Declaration", func() { | ||
It("fails with no model", func() { | ||
model, err := New("not-existing") | ||
Expect(err).To(HaveOccurred()) | ||
Expect(model).To(BeNil()) | ||
}) | ||
}) | ||
Context("Inferencing tests (using "+testModelPath+") ", func() { | ||
getModel := func() (*LLama, error) { | ||
model, err := New( | ||
testModelPath, | ||
EnableF16Memory, | ||
SetContext(128), | ||
SetMMap(true), | ||
SetNBatch(512), | ||
) | ||
Expect(err).ToNot(HaveOccurred()) | ||
Expect(model).ToNot(BeNil()) | ||
return model, err | ||
} | ||
|
||
It("predicts successfully", func() { | ||
if testModelPath == "" { | ||
Skip("test skipped - only makes sense if the TEST_MODEL environment variable is set.") | ||
} | ||
|
||
model, err := getModel() | ||
text, err := model.Predict(`Below is an instruction that describes a task. Write a response that appropriately completes the request. | ||
### Instruction: How much is 2+2? | ||
### Response: `, SetRopeFreqBase(10000.0), SetRopeFreqScale(1)) | ||
Expect(err).ToNot(HaveOccurred()) | ||
Expect(text).To(ContainSubstring("4")) | ||
}) | ||
|
||
It("tokenizes strings successfully", func() { | ||
if testModelPath == "" { | ||
Skip("test skipped - only makes sense if the TEST_MODEL environment variable is set.") | ||
} | ||
|
||
model, err := getModel() | ||
l, tokens, err := model.TokenizeString("A STRANGE GAME.\nTHE ONLY WINNING MOVE IS NOT TO PLAY.\n\nHOW ABOUT A NICE GAME OF CHESS?", | ||
SetRopeFreqBase(10000.0), SetRopeFreqScale(1)) | ||
|
||
Expect(err).ToNot(HaveOccurred()) | ||
Expect(l).To(BeNumerically(">", 0)) | ||
Expect(int(l)).To(Equal(len(tokens))) | ||
}) | ||
}) | ||
}) |