Skip to content
Snippets Groups Projects

Add interface for using generic CoreML LLMs

Merged Abhinav Jain requested to merge compile_cmd_line_generic_model_broken into main
Files
3
@@ -39,9 +39,19 @@ public macro MODEL_VALIDATE_NAME_AND_SET_INPUT_SIZE() = #externalMacro(
@@ -39,9 +39,19 @@ public macro MODEL_VALIDATE_NAME_AND_SET_INPUT_SIZE() = #externalMacro(
class CoreMLEncoder<Scalar: BinaryFloatingPoint & Codable>: SNLPEncoder {
class CoreMLEncoder<Scalar: BinaryFloatingPoint & Codable>: SNLPEncoder {
 
 
var zeroes: [Scalar]
var zeroes: [Scalar]
 
var dimensions: UInt
var model: String
var model: String
 
required init() {
 
zeroes = []
 
dimensions = 0
 
model = "all-MiniLM-L6-v2"
 
}
 
 
func encodeToken(_ token: String) -> [Scalar] {
func encodeToken(_ token: String) -> [Scalar] {
let tokenization = LLMEmbeddings(model_type: self.model).tokenizer.tokenizeToIds(text: token) as! [Scalar]
let tokenization = LLMEmbeddings(model_type: self.model).tokenizer.tokenizeToIds(text: token) as! [Scalar]
return tokenization
return tokenization
Loading