huggingface / swift-coreml-transformers

Swift Core ML 3 implementations of GPT-2, DistilGPT-2, BERT, and DistilBERT for Question answering. Other Transformers coming soon!
Apache License 2.0
1.62k stars 179 forks source link

Switch back to gpt2 512 model. Fixes gibberish gpt2 output #29

Open djsamseng opened 2 years ago

djsamseng commented 2 years ago

Switches back to the GPT2 512 model that was used for the demo on the README. While slower, the results match the quality of the README's demo.

Current (distilgpt2_64_6) These changes (gpt2_512)
distilgpt2_64_6 gpt2_512
distilgpt2_64_6 gpt2_512
distilgpt2_64_6 gpt2_512
realcarlos commented 1 year ago

Hi , I want to try:

private let model = gpt2_512()
public let tokenizer = GPT2Tokenizer()
public let seqLen = 512

but got errors, could you help to tell the what I should do? /Users/xxx/swift-coreml-transformers/Sources/GPT2.swift:29:25 Cannot find 'gpt2_512' in scope

djsamseng commented 1 year ago

Hi , I want to try:

private let model = gpt2_512()
public let tokenizer = GPT2Tokenizer()
public let seqLen = 512

but got errors, could you help to tell the what I should do? /Users/xxx/swift-coreml-transformers/Sources/GPT2.swift:29:25 Cannot find 'gpt2_512' in scope

Hello! Did you add the model to the project/build? https://github.com/huggingface/swift-coreml-transformers/pull/29/files#diff-2d85bd611302dc0e5de877b114c903d4047fccb7312ce3f9125b52bfc3144194R71

realcarlos commented 1 year ago

Hi , I want to try:

private let model = gpt2_512()
public let tokenizer = GPT2Tokenizer()
public let seqLen = 512

but got errors, could you help to tell the what I should do? /Users/xxx/swift-coreml-transformers/Sources/GPT2.swift:29:25 Cannot find 'gpt2_512' in scope

Hello! Did you add the model to the project/build? https://github.com/huggingface/swift-coreml-transformers/pull/29/files#diff-2d85bd611302dc0e5de877b114c903d4047fccb7312ce3f9125b52bfc3144194R71

yes, I have the model , it seems I missed the file which having gpt2_512() , could you tell me which file I should add?

djsamseng commented 1 year ago

Should be this one https://github.com/huggingface/swift-coreml-transformers/blob/master/Resources/gpt2-512.mlmodel

realcarlos commented 1 year ago

Should be this one https://github.com/huggingface/swift-coreml-transformers/blob/master/Resources/gpt2-512.mlmodel

I add this file to Compile Sources, but still failed:

2023-05-18 21:51:38.157876+0800 CoreMLGPT2[38603:9307067] Metal API Validation Enabled 2023-05-18 21:51:51.294500+0800 CoreMLGPT2[38603:9307067] [espresso] [Espresso::handle_ex_plan] exception=ANECF error: failed to load ANE model. Error=ANECCompile(/var/mobile/Library/Caches/com.apple.aned/tmp/ai.katia.Katia.CoreMLGPT2/6F284D8730500443BBF24C75BC12B6C3C41CC90940F082B78438ACA25771C66B/1D4509F6B6CDC93B38ECBC87E6282B6193403F9DA75BD53D25DD3A58D2AC3AE1/) FAILED: err=( CompilationFailure ) 2023-05-18 21:51:51.296062+0800 CoreMLGPT2[38603:9307067] [coreml] Error plan build: -1. 2023-05-18 21:51:51.308255+0800 CoreMLGPT2[38603:9307067] [client] doUnloadModel:options:qos:error:: nil _ANEModel 2023-05-18 21:51:51.308282+0800 CoreMLGPT2[38603:9307067] [espresso] ANECF error:

kpacholak commented 1 year ago

+1 from me