LanguageModel
LanguageModel.swift:13class LanguageModel
class LanguageModel
import Models
protocol Copyable
A type whose values can be implicitly or explicitly copied.
protocol Escapable
protocol Generation
protocol LanguageModelProtocol
protocol TextGenerationModel : Generation, LanguageModelProtocol
required init(model: MLModel)
static func loadCompiled(url: URL, computeUnits: MLComputeUnits = .cpuAndGPU) throws -> LanguageModel
var bosTokenId: Int? { get async throws }
var defaultDoSample: Bool { get async throws }
var defaultGenerationConfig: GenerationConfig { get }
var description: String { get }
var eosTokenId: Int? { get async throws }
var inputIdsDescription: MLFeatureDescription { get }
var inputIdsName: String { get }
var inputIdsShape: [Int] { get }
The expected shape of the models latent sample input
let maxContextLength: Int
let minContextLength: Int
let model: MLModel
var modelConfig: Config { get async throws }
var modelName: String { get }
var modelType: String? { get async throws }
var requiresAttention: Bool { get }
var textGenerationParameters: Config? { get async throws }
var tokenizer: Tokenizer { get async throws }
var tokenizerConfig: Config? { get async throws }
var tokenizerData: Config { get async throws }
func predictNextTokenScores(_ tokens: InputTokens, config: GenerationConfig) -> any MLShapedArrayProtocol
func callAsFunction(_ tokens: InputTokens, config: GenerationConfig) -> any MLShapedArrayProtocol
@discardableResult func generate(config: GenerationConfig, prompt: String, callback: PredictionStringCallback? = nil) async throws -> String
func generate(config: GenerationConfig, prompt: String, model: NextTokenModel, tokenizer: Tokenizer, callback: PredictionStringCallback? = nil) async -> String
func greedySearch(config: GenerationConfig, tokens: InputTokens, model: NextTokenModel, callback: PredictionTokensCallback? = nil) async -> GenerationOutput
func sample(config: GenerationConfig, tokens: InputTokens, model: NextTokenModel, callback: PredictionTokensCallback? = nil) async -> GenerationOutput
https://github.com/huggingface/transformers/blob/42017d82baa083da2bee3055fdac80c81ee97b8a/src/transformers/generation/utils.py#L1552