fact
stringlengths
18
2.71k
type
stringclasses
5 values
library
stringclasses
4 values
imports
listlengths
0
7
filename
stringclasses
18 values
symbolic_name
stringlengths
3
28
docstring
stringclasses
19 values
encode (name : @& String) (inputTokens : @& Array String) : FloatArray @[extern "init_premise_embeddings"]
opaque
LeanCopilot
[ "import Lean", "import LeanCopilot.Models.Interface", "import LeanCopilot.Models.Native", "import LeanCopilot.Models.Builtin" ]
LeanCopilot/Models/FFI.lean
encode
null
initPremiseEmbeddings (path : @& String) (device : @& String) : Bool @[extern "premise_embeddings_initialized"]
opaque
LeanCopilot
[ "import Lean", "import LeanCopilot.Models.Interface", "import LeanCopilot.Models.Native", "import LeanCopilot.Models.Builtin" ]
LeanCopilot/Models/FFI.lean
initPremiseEmbeddings
null
premiseEmbeddingsInitialized : Unit → Bool @[extern "init_premise_dictionary"]
opaque
LeanCopilot
[ "import Lean", "import LeanCopilot.Models.Interface", "import LeanCopilot.Models.Native", "import LeanCopilot.Models.Builtin" ]
LeanCopilot/Models/FFI.lean
premiseEmbeddingsInitialized
null
initPremiseDictionary (path : @& String) : Bool @[extern "premise_dictionary_initialized"]
opaque
LeanCopilot
[ "import Lean", "import LeanCopilot.Models.Interface", "import LeanCopilot.Models.Native", "import LeanCopilot.Models.Builtin" ]
LeanCopilot/Models/FFI.lean
initPremiseDictionary
null
premiseDictionaryInitialized : Unit → Bool @[extern "retrieve"]
opaque
LeanCopilot
[ "import Lean", "import LeanCopilot.Models.Interface", "import LeanCopilot.Models.Native", "import LeanCopilot.Models.Builtin" ]
LeanCopilot/Models/FFI.lean
premiseDictionaryInitialized
null
retrieve (queryEmb : @& FloatArray) (k : UInt64) : Array (String × String × String × Float) @[extern "cuda_available"]
opaque
LeanCopilot
[ "import Lean", "import LeanCopilot.Models.Interface", "import LeanCopilot.Models.Native", "import LeanCopilot.Models.Builtin" ]
LeanCopilot/Models/FFI.lean
retrieve
null
cudaAvailable : Unit → Bool
opaque
LeanCopilot
[ "import Lean", "import LeanCopilot.Models.Interface", "import LeanCopilot.Models.Native", "import LeanCopilot.Models.Builtin" ]
LeanCopilot/Models/FFI.lean
cudaAvailable
null
cudaAvailable : Bool := FFI.cudaAvailable () namespace NativeGenerator
def
LeanCopilot
[ "import Lean", "import LeanCopilot.Models.Interface", "import LeanCopilot.Models.Native", "import LeanCopilot.Models.Builtin" ]
LeanCopilot/Models/FFI.lean
cudaAvailable
null
generate (model : NativeGenerator) (input : String) (targetPrefix : String) : IO $ Array (String × Float) := do if ¬ FFI.isGeneratorInitialized model.name then let path ← model.path if ¬ (← path.pathExists) then throw $ IO.userError s!"Cannot find the model {model.name}. Please run `lake exe download {model.url}`." let...
def
LeanCopilot
[ "import Lean", "import LeanCopilot.Models.Interface", "import LeanCopilot.Models.Native", "import LeanCopilot.Models.Builtin" ]
LeanCopilot/Models/FFI.lean
generate
null
encode (model : NativeEncoder) (input : String) : IO FloatArray := do if ¬ FFI.isEncoderInitialized model.name then let path ← model.path if ¬ (← path.pathExists) then throw $ IO.userError s!"Cannot find the model {model.name}. Please run `lake exe download {model.url}`." let device := model.device.toString let compute...
def
LeanCopilot
[ "import Lean", "import LeanCopilot.Models.Interface", "import LeanCopilot.Models.Native", "import LeanCopilot.Models.Builtin" ]
LeanCopilot/Models/FFI.lean
encode
null
premiseEmbeddingsInitialized : IO Bool := do return FFI.premiseEmbeddingsInitialized ()
def
LeanCopilot
[ "import Lean", "import LeanCopilot.Models.Interface", "import LeanCopilot.Models.Native", "import LeanCopilot.Models.Builtin" ]
LeanCopilot/Models/FFI.lean
premiseEmbeddingsInitialized
null
initPremiseEmbeddings (device : Device) : Lean.CoreM Bool := do let url := Builtin.premisesUrl if ¬(← isUpToDate url) then Lean.logWarning s!"The local premise embeddings are not up to date. You may want to run `lake exe LeanCopilot/download` to re-download it." let path := (← getModelDir url) / "embeddings.npy" if ¬ (...
def
LeanCopilot
[ "import Lean", "import LeanCopilot.Models.Interface", "import LeanCopilot.Models.Native", "import LeanCopilot.Models.Builtin" ]
LeanCopilot/Models/FFI.lean
initPremiseEmbeddings
null
premiseDictionaryInitialized : IO Bool := do return FFI.premiseDictionaryInitialized ()
def
LeanCopilot
[ "import Lean", "import LeanCopilot.Models.Interface", "import LeanCopilot.Models.Native", "import LeanCopilot.Models.Builtin" ]
LeanCopilot/Models/FFI.lean
premiseDictionaryInitialized
null
initPremiseDictionary : IO Bool := do let path := (← getModelDir Builtin.premisesUrl) / "dictionary.json" if ¬ (← path.pathExists) then throw $ IO.userError s!"Please run `lake exe download {Builtin.premisesUrl}` to download the premise dictionary." return false return FFI.initPremiseDictionary path.toString
def
LeanCopilot
[ "import Lean", "import LeanCopilot.Models.Interface", "import LeanCopilot.Models.Native", "import LeanCopilot.Models.Builtin" ]
LeanCopilot/Models/FFI.lean
initPremiseDictionary
null
GenericGenerator where generate : String → String → IO (Array (String × Float))
structure
LeanCopilot
[ "import LeanCopilot.Models.Interface" ]
LeanCopilot/Models/Generic.lean
GenericGenerator
null
GenericEncoder where encode : String → IO FloatArray
structure
LeanCopilot
[ "import LeanCopilot.Models.Interface" ]
LeanCopilot/Models/Generic.lean
GenericEncoder
null
TextToText (τ : Type) where generate (model : τ) (input : String) (targetPrefix : String) : IO $ Array (String × Float)
class
LeanCopilot
[]
LeanCopilot/Models/Interface.lean
TextToText
null
TextToVec (τ : Type) where encode : τ → String → IO FloatArray
class
LeanCopilot
[]
LeanCopilot/Models/Interface.lean
TextToVec
null
generate {τ : Type} [TextToText τ] (model : τ) (input : String) (targetPrefix : String := "") : IO $ Array (String × Float) := TextToText.generate model input targetPrefix
def
LeanCopilot
[]
LeanCopilot/Models/Interface.lean
generate
null
encode {τ : Type} [TextToVec τ] (model : τ) (input : String) : IO FloatArray := TextToVec.encode model input
def
LeanCopilot
[]
LeanCopilot/Models/Interface.lean
encode
null
Device where | cpu | cuda | auto deriving Repr
inductive
LeanCopilot
[ "import ModelCheckpointManager" ]
LeanCopilot/Models/Native.lean
Device
null
Device.toString : Device → String | Device.cpu => "cpu" | Device.cuda => "cuda" | Device.auto => "auto"
def
LeanCopilot
[ "import ModelCheckpointManager" ]
LeanCopilot/Models/Native.lean
Device.toString
null
ComputeType where | default | auto | int8 | int8_float32 | int8_float16 | int8_bfloat16 | int16 | float16 | bfloat16 | float32 deriving Repr
inductive
LeanCopilot
[ "import ModelCheckpointManager" ]
LeanCopilot/Models/Native.lean
ComputeType
null
ComputeType.toString : ComputeType → String | ComputeType.default => "default" | ComputeType.auto => "auto" | ComputeType.int8 => "int8" | ComputeType.int8_float32 => "int8_float32" | ComputeType.int8_float16 => "int8_float16" | ComputeType.int8_bfloat16 => "int8_bfloat16" | ComputeType.int16 => "int16" | ComputeType.f...
def
LeanCopilot
[ "import ModelCheckpointManager" ]
LeanCopilot/Models/Native.lean
ComputeType.toString
null
Tokenizer where tokenize : String → Array String detokenize : Array String → String eosToken : String
structure
LeanCopilot
[ "import ModelCheckpointManager" ]
LeanCopilot/Models/Native.lean
Tokenizer
null
NativeModel where url : Url device : Device := .auto deviceIndex : Array UInt64 := #[0] computeType : ComputeType := .default tokenizer : Tokenizer
structure
LeanCopilot
[ "import ModelCheckpointManager" ]
LeanCopilot/Models/Native.lean
NativeModel
null
NativeModel.name (model : NativeModel) : String := model.url.name!
def
LeanCopilot
[ "import ModelCheckpointManager" ]
LeanCopilot/Models/Native.lean
NativeModel.name
null
NativeModel.path (model : NativeModel) : IO FilePath := getModelDir model.url
def
LeanCopilot
[ "import ModelCheckpointManager" ]
LeanCopilot/Models/Native.lean
NativeModel.path
null
BeamSearchParams where numReturnSequences : UInt64 beamSize : UInt64 := numReturnSequences minLength : UInt64 := 1 maxLength : UInt64 := 1024 lengthPenalty : Float := 0.0 patience : Float := 2.0 temperature : Float := 1.0 deriving Repr
structure
LeanCopilot
[ "import ModelCheckpointManager" ]
LeanCopilot/Models/Native.lean
BeamSearchParams
null
NativeGenerator extends NativeModel where params : BeamSearchParams
structure
LeanCopilot
[ "import ModelCheckpointManager" ]
LeanCopilot/Models/Native.lean
NativeGenerator
null
NativeEncoder extends NativeModel
structure
LeanCopilot
[ "import ModelCheckpointManager" ]
LeanCopilot/Models/Native.lean
NativeEncoder
null
Generator where | native : NativeGenerator → Generator | external : ExternalGenerator → Generator | generic : GenericGenerator → Generator
inductive
LeanCopilot
[ "import Lean", "import Batteries.Data.HashMap", "import LeanCopilot.Models.Native", "import LeanCopilot.Models.External", "import LeanCopilot.Models.Generic", "import LeanCopilot.Models.Builtin", "import LeanCopilot.Models.FFI" ]
LeanCopilot/Models/Registry.lean
Generator
null
Encoder where | native : NativeEncoder → Encoder | external : ExternalEncoder → Encoder | generic : GenericEncoder → Encoder
inductive
LeanCopilot
[ "import Lean", "import Batteries.Data.HashMap", "import LeanCopilot.Models.Native", "import LeanCopilot.Models.External", "import LeanCopilot.Models.Generic", "import LeanCopilot.Models.Builtin", "import LeanCopilot.Models.FFI" ]
LeanCopilot/Models/Registry.lean
Encoder
null
ModelRegistry where generators : Std.HashMap String Generator := Std.HashMap.ofList [(Builtin.generator.name, .native Builtin.generator)] encoders : Std.HashMap String Encoder := Std.HashMap.ofList [(Builtin.encoder.name, .native Builtin.encoder)] namespace ModelRegistry
structure
LeanCopilot
[ "import Lean", "import Batteries.Data.HashMap", "import LeanCopilot.Models.Native", "import LeanCopilot.Models.External", "import LeanCopilot.Models.Generic", "import LeanCopilot.Models.Builtin", "import LeanCopilot.Models.FFI" ]
LeanCopilot/Models/Registry.lean
ModelRegistry
null
generatorNames (mr : ModelRegistry) : List String := mr.generators.toList.map (·.1)
def
LeanCopilot
[ "import Lean", "import Batteries.Data.HashMap", "import LeanCopilot.Models.Native", "import LeanCopilot.Models.External", "import LeanCopilot.Models.Generic", "import LeanCopilot.Models.Builtin", "import LeanCopilot.Models.FFI" ]
LeanCopilot/Models/Registry.lean
generatorNames
null
encoderNames (mr : ModelRegistry) : List String := mr.encoders.toList.map (·.1)
def
LeanCopilot
[ "import Lean", "import Batteries.Data.HashMap", "import LeanCopilot.Models.Native", "import LeanCopilot.Models.External", "import LeanCopilot.Models.Generic", "import LeanCopilot.Models.Builtin", "import LeanCopilot.Models.FFI" ]
LeanCopilot/Models/Registry.lean
encoderNames
null
modelNames (mr : ModelRegistry) : List String := mr.generatorNames ++ mr.encoderNames
def
LeanCopilot
[ "import Lean", "import Batteries.Data.HashMap", "import LeanCopilot.Models.Native", "import LeanCopilot.Models.External", "import LeanCopilot.Models.Generic", "import LeanCopilot.Models.Builtin", "import LeanCopilot.Models.FFI" ]
LeanCopilot/Models/Registry.lean
modelNames
null
getModelRegistry : IO ModelRegistry := modelRegistryRef.get
def
LeanCopilot
[ "import Lean", "import Batteries.Data.HashMap", "import LeanCopilot.Models.Native", "import LeanCopilot.Models.External", "import LeanCopilot.Models.Generic", "import LeanCopilot.Models.Builtin", "import LeanCopilot.Models.FFI" ]
LeanCopilot/Models/Registry.lean
getModelRegistry
null
getGenerator (name : String) : Lean.CoreM Generator := do let mr ← getModelRegistry match mr.generators[name]? with | some (.native model) => if ¬(← isUpToDate model.url) then Lean.logWarning s!"The local model {model.name} is not up to date. You may want to run `lake exe LeanCopilot/download` to re-download it." retur...
def
LeanCopilot
[ "import Lean", "import Batteries.Data.HashMap", "import LeanCopilot.Models.Native", "import LeanCopilot.Models.External", "import LeanCopilot.Models.Generic", "import LeanCopilot.Models.Builtin", "import LeanCopilot.Models.FFI" ]
LeanCopilot/Models/Registry.lean
getGenerator
null
getEncoder (name : String) : IO Encoder := do let mr ← getModelRegistry match mr.encoders[name]? with | some descr => return descr | none => throw $ IO.userError s!"unknown encoder: {name}"
def
LeanCopilot
[ "import Lean", "import Batteries.Data.HashMap", "import LeanCopilot.Models.Native", "import LeanCopilot.Models.External", "import LeanCopilot.Models.Generic", "import LeanCopilot.Models.Builtin", "import LeanCopilot.Models.FFI" ]
LeanCopilot/Models/Registry.lean
getEncoder
null
registerGenerator (name : String) (model : Generator) := do let mr ← getModelRegistry modelRegistryRef.modify fun _ => {mr with generators := mr.generators.insert name model}
def
LeanCopilot
[ "import Lean", "import Batteries.Data.HashMap", "import LeanCopilot.Models.Native", "import LeanCopilot.Models.External", "import LeanCopilot.Models.Generic", "import LeanCopilot.Models.Builtin", "import LeanCopilot.Models.FFI" ]
LeanCopilot/Models/Registry.lean
registerGenerator
null