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
4
@@ -39,9 +39,19 @@ public macro MODEL_VALIDATE_NAME_AND_SET_INPUT_SIZE() = #externalMacro(
class CoreMLEncoder<Scalar: BinaryFloatingPoint & Codable>: SNLPEncoder {
var zeroes: [Scalar]
var dimensions: UInt
var model: String
required init() {
zeroes = Array(repeating: Scalar(0), count: 384)
dimensions = 384
model = "all_MiniLM_L6_v2"
}
func encodeToken(_ token: String) -> [Scalar] {
let tokenization = LLMEmbeddings(model_type: self.model).tokenizer.tokenizeToIds(text: token) as! [Scalar]
return tokenization
Loading