id stringlengths 14 16 | text stringlengths 4 1.28k | source stringlengths 54 121 |
|---|---|---|
0e0436a883fe-511 | Parameters
_fields_set (Optional[SetStr]) –
values (Any) –
Return type
Model
copy(*, include=None, exclude=None, update=None, deep=False)
Duplicate a model, optionally choose which fields to include, exclude and change.
Parameters
include (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) – fields to include in ... | https://api.python.langchain.com/en/latest/modules/llms.html |
0e0436a883fe-512 | Model
dict(**kwargs)
Return a dictionary of the LLM.
Parameters
kwargs (Any) –
Return type
Dict
generate(prompts, stop=None, callbacks=None, *, tags=None, **kwargs)
Run the LLM on the given prompt and input.
Parameters
prompts (List[str]) –
stop (Optional[List[str]]) –
callbacks (Optional[Union[List[langchain.call... | https://api.python.langchain.com/en/latest/modules/llms.html |
0e0436a883fe-513 | stop (Optional[List[str]]) –
callbacks (Optional[Union[List[langchain.callbacks.base.BaseCallbackHandler], langchain.callbacks.base.BaseCallbackManager]]) –
kwargs (Any) –
Return type
langchain.schema.LLMResult
get_num_tokens(text)
Get the number of tokens present in the text.
Parameters
text (str) –
Return type
i... | https://api.python.langchain.com/en/latest/modules/llms.html |
0e0436a883fe-514 | Return type
List[int]
json(*, include=None, exclude=None, by_alias=False, skip_defaults=None, exclude_unset=False, exclude_defaults=False, exclude_none=False, encoder=None, models_as_dict=True, **dumps_kwargs)
Generate a JSON representation of the model, include and exclude arguments as per dict().
encoder is an optio... | https://api.python.langchain.com/en/latest/modules/llms.html |
0e0436a883fe-515 | models_as_dict (bool) –
dumps_kwargs (Any) –
Return type
unicode
predict(text, *, stop=None, **kwargs)
Predict text from text.
Parameters
text (str) –
stop (Optional[Sequence[str]]) –
kwargs (Any) –
Return type
str
predict_messages(messages, *, stop=None, **kwargs)
Predict message from messages.
Parameters
messa... | https://api.python.langchain.com/en/latest/modules/llms.html |
0e0436a883fe-516 | classmethod update_forward_refs(**localns)
Try to update ForwardRefs on fields based on this Model, globalns and localns.
Parameters
localns (Any) –
Return type
None
property lc_attributes: Dict
Return a list of attribute names that should be included in the
serialized kwargs. These attributes must be accepted by th... | https://api.python.langchain.com/en/latest/modules/llms.html |
0e0436a883fe-517 | class langchain.llms.RWKV(*, cache=None, verbose=None, callbacks=None, callback_manager=None, tags=None, model, tokens_path, strategy='cpu fp32', rwkv_verbose=True, temperature=1.0, top_p=0.5, penalty_alpha_frequency=0.4, penalty_alpha_presence=0.4, CHUNK_LEN=256, max_tokens_per_generation=256, client=None, tokenizer=N... | https://api.python.langchain.com/en/latest/modules/llms.html |
0e0436a883fe-518 | # Simplest invocation
response = model("Once upon a time, ")
Parameters
cache (Optional[bool]) –
verbose (bool) –
callbacks (Optional[Union[List[langchain.callbacks.base.BaseCallbackHandler], langchain.callbacks.base.BaseCallbackManager]]) –
callback_manager (Optional[langchain.callbacks.base.BaseCallbackManager]) –... | https://api.python.langchain.com/en/latest/modules/llms.html |
0e0436a883fe-519 | model_tokens (Any) –
model_state (Any) –
Return type
None
attribute CHUNK_LEN: int = 256
Batch size for prompt processing.
attribute max_tokens_per_generation: int = 256
Maximum number of tokens to generate.
attribute model: str [Required]
Path to the pre-trained RWKV model file.
attribute penalty_alpha_frequency:... | https://api.python.langchain.com/en/latest/modules/llms.html |
0e0436a883fe-520 | Print debug information.
attribute strategy: str = 'cpu fp32'
Token context window.
attribute tags: Optional[List[str]] = None
Tags to add to the run trace.
attribute temperature: float = 1.0
The temperature to use for sampling.
attribute tokens_path: str [Required]
Path to the RWKV tokens file.
attribute top_p: fl... | https://api.python.langchain.com/en/latest/modules/llms.html |
0e0436a883fe-521 | stop (Optional[List[str]]) –
callbacks (Optional[Union[List[langchain.callbacks.base.BaseCallbackHandler], langchain.callbacks.base.BaseCallbackManager]]) –
kwargs (Any) –
Return type
str
async agenerate(prompts, stop=None, callbacks=None, *, tags=None, **kwargs)
Run the LLM on the given prompt and input.
Parameter... | https://api.python.langchain.com/en/latest/modules/llms.html |
0e0436a883fe-522 | Parameters
prompts (List[langchain.schema.PromptValue]) –
stop (Optional[List[str]]) –
callbacks (Optional[Union[List[langchain.callbacks.base.BaseCallbackHandler], langchain.callbacks.base.BaseCallbackManager]]) –
kwargs (Any) –
Return type
langchain.schema.LLMResult
async apredict(text, *, stop=None, **kwargs)
P... | https://api.python.langchain.com/en/latest/modules/llms.html |
0e0436a883fe-523 | Creates a new model setting __dict__ and __fields_set__ from trusted or pre-validated data.
Default values are respected, but no other validation is performed.
Behaves as if Config.extra = ‘allow’ was set since it adds all passed values
Parameters
_fields_set (Optional[SetStr]) –
values (Any) –
Return type
Model
copy... | https://api.python.langchain.com/en/latest/modules/llms.html |
0e0436a883fe-524 | the new model: you should trust this data
deep (bool) – set to True to make a deep copy of the model
self (Model) –
Returns
new model instance
Return type
Model
dict(**kwargs)
Return a dictionary of the LLM.
Parameters
kwargs (Any) –
Return type
Dict
generate(prompts, stop=None, callbacks=None, *, tags=None, **kwarg... | https://api.python.langchain.com/en/latest/modules/llms.html |
0e0436a883fe-525 | Take in a list of prompt values and return an LLMResult.
Parameters
prompts (List[langchain.schema.PromptValue]) –
stop (Optional[List[str]]) –
callbacks (Optional[Union[List[langchain.callbacks.base.BaseCallbackHandler], langchain.callbacks.base.BaseCallbackManager]]) –
kwargs (Any) –
Return type
langchain.schema.... | https://api.python.langchain.com/en/latest/modules/llms.html |
0e0436a883fe-526 | Return type
List[int]
json(*, include=None, exclude=None, by_alias=False, skip_defaults=None, exclude_unset=False, exclude_defaults=False, exclude_none=False, encoder=None, models_as_dict=True, **dumps_kwargs)
Generate a JSON representation of the model, include and exclude arguments as per dict().
encoder is an optio... | https://api.python.langchain.com/en/latest/modules/llms.html |
0e0436a883fe-527 | models_as_dict (bool) –
dumps_kwargs (Any) –
Return type
unicode
predict(text, *, stop=None, **kwargs)
Predict text from text.
Parameters
text (str) –
stop (Optional[Sequence[str]]) –
kwargs (Any) –
Return type
str
predict_messages(messages, *, stop=None, **kwargs)
Predict message from messages.
Parameters
messa... | https://api.python.langchain.com/en/latest/modules/llms.html |
0e0436a883fe-528 | classmethod update_forward_refs(**localns)
Try to update ForwardRefs on fields based on this Model, globalns and localns.
Parameters
localns (Any) –
Return type
None
property lc_attributes: Dict
Return a list of attribute names that should be included in the
serialized kwargs. These attributes must be accepted by th... | https://api.python.langchain.com/en/latest/modules/llms.html |
0e0436a883fe-529 | class langchain.llms.Replicate(*, cache=None, verbose=None, callbacks=None, callback_manager=None, tags=None, model, input=None, model_kwargs=None, replicate_api_token=None)[source]
Bases: langchain.llms.base.LLM
Wrapper around Replicate models.
To use, you should have the replicate python package installed,
and the e... | https://api.python.langchain.com/en/latest/modules/llms.html |
0e0436a883fe-530 | from langchain.llms import Replicate
replicate = Replicate(model="stability-ai/stable-diffusion: 27b93a2413e7f36cd83da926f365628 0b2931564ff050bf9575f1fdf9bcd7478",
input={"image_dimensions": "512x512"})
Parameters
ca... | https://api.python.langchain.com/en/latest/modules/llms.html |
0e0436a883fe-531 | Return type
None
attribute tags: Optional[List[str]] = None
Tags to add to the run trace.
attribute verbose: bool [Optional]
Whether to print out response text.
__call__(prompt, stop=None, callbacks=None, **kwargs)
Check Cache and run the LLM on the given prompt and input.
Parameters
prompt (str) –
stop (Optional[L... | https://api.python.langchain.com/en/latest/modules/llms.html |
0e0436a883fe-532 | stop (Optional[List[str]]) –
callbacks (Optional[Union[List[langchain.callbacks.base.BaseCallbackHandler], langchain.callbacks.base.BaseCallbackManager]]) –
tags (Optional[List[str]]) –
kwargs (Any) –
Return type
langchain.schema.LLMResult
async agenerate_prompt(prompts, stop=None, callbacks=None, **kwargs)
Take i... | https://api.python.langchain.com/en/latest/modules/llms.html |
0e0436a883fe-533 | Parameters
text (str) –
stop (Optional[Sequence[str]]) –
kwargs (Any) –
Return type
str
async apredict_messages(messages, *, stop=None, **kwargs)
Predict message from messages.
Parameters
messages (List[langchain.schema.BaseMessage]) –
stop (Optional[Sequence[str]]) –
kwargs (Any) –
Return type
langchain.schema.... | https://api.python.langchain.com/en/latest/modules/llms.html |
0e0436a883fe-534 | Return type
Model
copy(*, include=None, exclude=None, update=None, deep=False)
Duplicate a model, optionally choose which fields to include, exclude and change.
Parameters
include (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) – fields to include in new model
exclude (Optional[Union[AbstractSetIntStr, MappingI... | https://api.python.langchain.com/en/latest/modules/llms.html |
0e0436a883fe-535 | kwargs (Any) –
Return type
Dict
generate(prompts, stop=None, callbacks=None, *, tags=None, **kwargs)
Run the LLM on the given prompt and input.
Parameters
prompts (List[str]) –
stop (Optional[List[str]]) –
callbacks (Optional[Union[List[langchain.callbacks.base.BaseCallbackHandler], langchain.callbacks.base.BaseCal... | https://api.python.langchain.com/en/latest/modules/llms.html |
0e0436a883fe-536 | kwargs (Any) –
Return type
langchain.schema.LLMResult
get_num_tokens(text)
Get the number of tokens present in the text.
Parameters
text (str) –
Return type
int
get_num_tokens_from_messages(messages)
Get the number of tokens in the message.
Parameters
messages (List[langchain.schema.BaseMessage]) –
Return type
int... | https://api.python.langchain.com/en/latest/modules/llms.html |
0e0436a883fe-537 | encoder is an optional function to supply as default to json.dumps(), other arguments as per json.dumps().
Parameters
include (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) –
exclude (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) –
by_alias (bool) –
skip_defaults (Optional[bool]) –
exclude_unset (bo... | https://api.python.langchain.com/en/latest/modules/llms.html |
0e0436a883fe-538 | Return type
str
predict_messages(messages, *, stop=None, **kwargs)
Predict message from messages.
Parameters
messages (List[langchain.schema.BaseMessage]) –
stop (Optional[Sequence[str]]) –
kwargs (Any) –
Return type
langchain.schema.BaseMessage
save(file_path)
Save the LLM.
Parameters
file_path (Union[pathlib.Pat... | https://api.python.langchain.com/en/latest/modules/llms.html |
0e0436a883fe-539 | serialized kwargs. These attributes must be accepted by the
constructor.
property lc_namespace: List[str]
Return the namespace of the langchain object.
eg. [“langchain”, “llms”, “openai”]
property lc_secrets: Dict[str, str]
Return a map of constructor argument names to secret ids.
eg. {“openai_api_key”: “OPENAI_API_K... | https://api.python.langchain.com/en/latest/modules/llms.html |
0e0436a883fe-540 | To use, you must supply the endpoint name from your deployed
Sagemaker model & the region where it is deployed.
To authenticate, the AWS client uses the following methods to
automatically load credentials:
https://boto3.amazonaws.com/v1/documentation/api/latest/guide/credentials.html
If a specific credential profile sh... | https://api.python.langchain.com/en/latest/modules/llms.html |
0e0436a883fe-541 | tags (Optional[List[str]]) –
client (Any) –
endpoint_name (str) –
region_name (str) –
credentials_profile_name (Optional[str]) –
content_handler (langchain.llms.sagemaker_endpoint.LLMContentHandler) –
model_kwargs (Optional[Dict]) –
endpoint_kwargs (Optional[Dict]) –
Return type
None
attribute content_handler: ... | https://api.python.langchain.com/en/latest/modules/llms.html |
0e0436a883fe-542 | credentials from IMDS will be used.
See: https://boto3.amazonaws.com/v1/documentation/api/latest/guide/credentials.html
attribute endpoint_kwargs: Optional[Dict] = None
Optional attributes passed to the invoke_endpoint
function. See `boto3`_. docs for more info.
.. _boto3: <https://boto3.amazonaws.com/v1/documentation... | https://api.python.langchain.com/en/latest/modules/llms.html |
0e0436a883fe-543 | Tags to add to the run trace.
attribute verbose: bool [Optional]
Whether to print out response text.
__call__(prompt, stop=None, callbacks=None, **kwargs)
Check Cache and run the LLM on the given prompt and input.
Parameters
prompt (str) –
stop (Optional[List[str]]) –
callbacks (Optional[Union[List[langchain.callba... | https://api.python.langchain.com/en/latest/modules/llms.html |
0e0436a883fe-544 | tags (Optional[List[str]]) –
kwargs (Any) –
Return type
langchain.schema.LLMResult
async agenerate_prompt(prompts, stop=None, callbacks=None, **kwargs)
Take in a list of prompt values and return an LLMResult.
Parameters
prompts (List[langchain.schema.PromptValue]) –
stop (Optional[List[str]]) –
callbacks (Optional... | https://api.python.langchain.com/en/latest/modules/llms.html |
0e0436a883fe-545 | Predict message from messages.
Parameters
messages (List[langchain.schema.BaseMessage]) –
stop (Optional[Sequence[str]]) –
kwargs (Any) –
Return type
langchain.schema.BaseMessage
classmethod construct(_fields_set=None, **values)
Creates a new model setting __dict__ and __fields_set__ from trusted or pre-validated d... | https://api.python.langchain.com/en/latest/modules/llms.html |
0e0436a883fe-546 | exclude (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) – fields to exclude from new model, as with values this takes precedence over include
update (Optional[DictStrAny]) – values to change/add in the new model. Note: the data is not validated before creating
the new model: you should trust this data
deep (bool... | https://api.python.langchain.com/en/latest/modules/llms.html |
0e0436a883fe-547 | stop (Optional[List[str]]) –
callbacks (Optional[Union[List[langchain.callbacks.base.BaseCallbackHandler], langchain.callbacks.base.BaseCallbackManager]]) –
tags (Optional[List[str]]) –
kwargs (Any) –
Return type
langchain.schema.LLMResult
generate_prompt(prompts, stop=None, callbacks=None, **kwargs)
Take in a lis... | https://api.python.langchain.com/en/latest/modules/llms.html |
0e0436a883fe-548 | Return type
int
get_num_tokens_from_messages(messages)
Get the number of tokens in the message.
Parameters
messages (List[langchain.schema.BaseMessage]) –
Return type
int
get_token_ids(text)
Get the token present in the text.
Parameters
text (str) –
Return type
List[int]
json(*, include=None, exclude=None, by_alias... | https://api.python.langchain.com/en/latest/modules/llms.html |
0e0436a883fe-549 | exclude (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) –
by_alias (bool) –
skip_defaults (Optional[bool]) –
exclude_unset (bool) –
exclude_defaults (bool) –
exclude_none (bool) –
encoder (Optional[Callable[[Any], Any]]) –
models_as_dict (bool) –
dumps_kwargs (Any) –
Return type
unicode
predict(text, *,... | https://api.python.langchain.com/en/latest/modules/llms.html |
0e0436a883fe-550 | kwargs (Any) –
Return type
langchain.schema.BaseMessage
save(file_path)
Save the LLM.
Parameters
file_path (Union[pathlib.Path, str]) – Path to file to save the LLM to.
Return type
None
Example:
.. code-block:: python
llm.save(file_path=”path/llm.yaml”)
classmethod update_forward_refs(**localns)
Try to update Forwar... | https://api.python.langchain.com/en/latest/modules/llms.html |
0e0436a883fe-551 | property lc_secrets: Dict[str, str]
Return a map of constructor argument names to secret ids.
eg. {“openai_api_key”: “OPENAI_API_KEY”}
property lc_serializable: bool
Return whether or not the class is serializable.
class langchain.llms.SelfHostedHuggingFaceLLM(*, cache=None, verbose=None, callbacks=None, callback_man... | https://api.python.langchain.com/en/latest/modules/llms.html |
0e0436a883fe-552 | Supported hardware includes auto-launched instances on AWS, GCP, Azure,
and Lambda, as well as servers specified
by IP address and SSH credentials (such as on-prem, or another cloud
like Paperspace, Coreweave, etc.).
To use, you should have the runhouse python package installed.
Only supports text-generation, text2text... | https://api.python.langchain.com/en/latest/modules/llms.html |
0e0436a883fe-553 | from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline
import runhouse as rh
def get_pipeline():
model_id = "gpt2"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(model_id)
pipe = pipeline(
"text-generation", model=model, tokenizer... | https://api.python.langchain.com/en/latest/modules/llms.html |
0e0436a883fe-554 | pipeline_ref (Any) –
client (Any) –
inference_fn (Callable) –
hardware (Any) –
model_load_fn (Callable) –
load_fn_kwargs (Optional[dict]) –
model_reqs (List[str]) –
model_id (str) –
task (str) –
device (int) –
model_kwargs (Optional[dict]) –
Return type
None
attribute device: int = 0
Device to use for infer... | https://api.python.langchain.com/en/latest/modules/llms.html |
0e0436a883fe-555 | Key word arguments to pass to the model load function.
attribute model_id: str = 'gpt2'
Hugging Face model_id to load the model.
attribute model_kwargs: Optional[dict] = None
Key word arguments to pass to the model.
attribute model_load_fn: Callable = <function _load_transformer>
Function to load the model remotely ... | https://api.python.langchain.com/en/latest/modules/llms.html |
0e0436a883fe-556 | Whether to print out response text.
__call__(prompt, stop=None, callbacks=None, **kwargs)
Check Cache and run the LLM on the given prompt and input.
Parameters
prompt (str) –
stop (Optional[List[str]]) –
callbacks (Optional[Union[List[langchain.callbacks.base.BaseCallbackHandler], langchain.callbacks.base.BaseCallba... | https://api.python.langchain.com/en/latest/modules/llms.html |
0e0436a883fe-557 | kwargs (Any) –
Return type
langchain.schema.LLMResult
async agenerate_prompt(prompts, stop=None, callbacks=None, **kwargs)
Take in a list of prompt values and return an LLMResult.
Parameters
prompts (List[langchain.schema.PromptValue]) –
stop (Optional[List[str]]) –
callbacks (Optional[Union[List[langchain.callback... | https://api.python.langchain.com/en/latest/modules/llms.html |
0e0436a883fe-558 | Predict message from messages.
Parameters
messages (List[langchain.schema.BaseMessage]) –
stop (Optional[Sequence[str]]) –
kwargs (Any) –
Return type
langchain.schema.BaseMessage
classmethod construct(_fields_set=None, **values)
Creates a new model setting __dict__ and __fields_set__ from trusted or pre-validated d... | https://api.python.langchain.com/en/latest/modules/llms.html |
0e0436a883fe-559 | exclude (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) – fields to exclude from new model, as with values this takes precedence over include
update (Optional[DictStrAny]) – values to change/add in the new model. Note: the data is not validated before creating
the new model: you should trust this data
deep (bool... | https://api.python.langchain.com/en/latest/modules/llms.html |
0e0436a883fe-560 | device (int) –
kwargs (Any) –
Return type
langchain.llms.base.LLM
generate(prompts, stop=None, callbacks=None, *, tags=None, **kwargs)
Run the LLM on the given prompt and input.
Parameters
prompts (List[str]) –
stop (Optional[List[str]]) –
callbacks (Optional[Union[List[langchain.callbacks.base.BaseCallbackHandler... | https://api.python.langchain.com/en/latest/modules/llms.html |
0e0436a883fe-561 | stop (Optional[List[str]]) –
callbacks (Optional[Union[List[langchain.callbacks.base.BaseCallbackHandler], langchain.callbacks.base.BaseCallbackManager]]) –
kwargs (Any) –
Return type
langchain.schema.LLMResult
get_num_tokens(text)
Get the number of tokens present in the text.
Parameters
text (str) –
Return type
i... | https://api.python.langchain.com/en/latest/modules/llms.html |
0e0436a883fe-562 | Return type
List[int]
json(*, include=None, exclude=None, by_alias=False, skip_defaults=None, exclude_unset=False, exclude_defaults=False, exclude_none=False, encoder=None, models_as_dict=True, **dumps_kwargs)
Generate a JSON representation of the model, include and exclude arguments as per dict().
encoder is an optio... | https://api.python.langchain.com/en/latest/modules/llms.html |
0e0436a883fe-563 | models_as_dict (bool) –
dumps_kwargs (Any) –
Return type
unicode
predict(text, *, stop=None, **kwargs)
Predict text from text.
Parameters
text (str) –
stop (Optional[Sequence[str]]) –
kwargs (Any) –
Return type
str
predict_messages(messages, *, stop=None, **kwargs)
Predict message from messages.
Parameters
messa... | https://api.python.langchain.com/en/latest/modules/llms.html |
0e0436a883fe-564 | classmethod update_forward_refs(**localns)
Try to update ForwardRefs on fields based on this Model, globalns and localns.
Parameters
localns (Any) –
Return type
None
property lc_attributes: Dict
Return a list of attribute names that should be included in the
serialized kwargs. These attributes must be accepted by th... | https://api.python.langchain.com/en/latest/modules/llms.html |
0e0436a883fe-565 | class langchain.llms.SelfHostedPipeline(*, cache=None, verbose=None, callbacks=None, callback_manager=None, tags=None, pipeline_ref=None, client=None, inference_fn=<function _generate_text>, hardware=None, model_load_fn, load_fn_kwargs=None, model_reqs=['./', 'torch'])[source]
Bases: langchain.llms.base.LLM
Run model ... | https://api.python.langchain.com/en/latest/modules/llms.html |
0e0436a883fe-566 | import runhouse as rh
def load_pipeline():
tokenizer = AutoTokenizer.from_pretrained("gpt2")
model = AutoModelForCausalLM.from_pretrained("gpt2")
return pipeline(
"text-generation", model=model, tokenizer=tokenizer,
max_new_tokens=10
)
def inference_fn(pipeline, prompt, stop = None):
... | https://api.python.langchain.com/en/latest/modules/llms.html |
0e0436a883fe-567 | import runhouse as rh
gpu = rh.cluster(name="rh-a10x", instance_type="A100:1")
my_model = ...
llm = SelfHostedPipeline.from_pipeline(
pipeline=my_model,
hardware=gpu,
model_reqs=["./", "torch", "transformers"],
)
Example passing model path for larger models:from langchain.llms import SelfHostedPipeline
impo... | https://api.python.langchain.com/en/latest/modules/llms.html |
0e0436a883fe-568 | cache (Optional[bool]) –
verbose (bool) –
callbacks (Optional[Union[List[langchain.callbacks.base.BaseCallbackHandler], langchain.callbacks.base.BaseCallbackManager]]) –
callback_manager (Optional[langchain.callbacks.base.BaseCallbackManager]) –
tags (Optional[List[str]]) –
pipeline_ref (Any) –
client (Any) –
in... | https://api.python.langchain.com/en/latest/modules/llms.html |
0e0436a883fe-569 | Key word arguments to pass to the model load function.
attribute model_load_fn: Callable [Required]
Function to load the model remotely on the server.
attribute model_reqs: List[str] = ['./', 'torch']
Requirements to install on hardware to inference the model.
attribute tags: Optional[List[str]] = None
Tags to add t... | https://api.python.langchain.com/en/latest/modules/llms.html |
0e0436a883fe-570 | Return type
str
async agenerate(prompts, stop=None, callbacks=None, *, tags=None, **kwargs)
Run the LLM on the given prompt and input.
Parameters
prompts (List[str]) –
stop (Optional[List[str]]) –
callbacks (Optional[Union[List[langchain.callbacks.base.BaseCallbackHandler], langchain.callbacks.base.BaseCallbackManag... | https://api.python.langchain.com/en/latest/modules/llms.html |
0e0436a883fe-571 | kwargs (Any) –
Return type
langchain.schema.LLMResult
async apredict(text, *, stop=None, **kwargs)
Predict text from text.
Parameters
text (str) –
stop (Optional[Sequence[str]]) –
kwargs (Any) –
Return type
str
async apredict_messages(messages, *, stop=None, **kwargs)
Predict message from messages.
Parameters
mes... | https://api.python.langchain.com/en/latest/modules/llms.html |
0e0436a883fe-572 | Parameters
_fields_set (Optional[SetStr]) –
values (Any) –
Return type
Model
copy(*, include=None, exclude=None, update=None, deep=False)
Duplicate a model, optionally choose which fields to include, exclude and change.
Parameters
include (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) – fields to include in ... | https://api.python.langchain.com/en/latest/modules/llms.html |
0e0436a883fe-573 | Model
dict(**kwargs)
Return a dictionary of the LLM.
Parameters
kwargs (Any) –
Return type
Dict
classmethod from_pipeline(pipeline, hardware, model_reqs=None, device=0, **kwargs)[source]
Init the SelfHostedPipeline from a pipeline object or string.
Parameters
pipeline (Any) –
hardware (Any) –
model_reqs (Optional[... | https://api.python.langchain.com/en/latest/modules/llms.html |
0e0436a883fe-574 | stop (Optional[List[str]]) –
callbacks (Optional[Union[List[langchain.callbacks.base.BaseCallbackHandler], langchain.callbacks.base.BaseCallbackManager]]) –
tags (Optional[List[str]]) –
kwargs (Any) –
Return type
langchain.schema.LLMResult
generate_prompt(prompts, stop=None, callbacks=None, **kwargs)
Take in a lis... | https://api.python.langchain.com/en/latest/modules/llms.html |
0e0436a883fe-575 | Return type
int
get_num_tokens_from_messages(messages)
Get the number of tokens in the message.
Parameters
messages (List[langchain.schema.BaseMessage]) –
Return type
int
get_token_ids(text)
Get the token present in the text.
Parameters
text (str) –
Return type
List[int]
json(*, include=None, exclude=None, by_alias... | https://api.python.langchain.com/en/latest/modules/llms.html |
0e0436a883fe-576 | exclude (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) –
by_alias (bool) –
skip_defaults (Optional[bool]) –
exclude_unset (bool) –
exclude_defaults (bool) –
exclude_none (bool) –
encoder (Optional[Callable[[Any], Any]]) –
models_as_dict (bool) –
dumps_kwargs (Any) –
Return type
unicode
predict(text, *,... | https://api.python.langchain.com/en/latest/modules/llms.html |
0e0436a883fe-577 | kwargs (Any) –
Return type
langchain.schema.BaseMessage
save(file_path)
Save the LLM.
Parameters
file_path (Union[pathlib.Path, str]) – Path to file to save the LLM to.
Return type
None
Example:
.. code-block:: python
llm.save(file_path=”path/llm.yaml”)
classmethod update_forward_refs(**localns)
Try to update Forwar... | https://api.python.langchain.com/en/latest/modules/llms.html |
0e0436a883fe-578 | property lc_secrets: Dict[str, str]
Return a map of constructor argument names to secret ids.
eg. {“openai_api_key”: “OPENAI_API_KEY”}
property lc_serializable: bool
Return whether or not the class is serializable.
class langchain.llms.StochasticAI(*, cache=None, verbose=None, callbacks=None, callback_manager=None, t... | https://api.python.langchain.com/en/latest/modules/llms.html |
0e0436a883fe-579 | verbose (bool) –
callbacks (Optional[Union[List[langchain.callbacks.base.BaseCallbackHandler], langchain.callbacks.base.BaseCallbackManager]]) –
callback_manager (Optional[langchain.callbacks.base.BaseCallbackManager]) –
tags (Optional[List[str]]) –
api_url (str) –
model_kwargs (Dict[str, Any]) –
stochasticai_api... | https://api.python.langchain.com/en/latest/modules/llms.html |
0e0436a883fe-580 | Check Cache and run the LLM on the given prompt and input.
Parameters
prompt (str) –
stop (Optional[List[str]]) –
callbacks (Optional[Union[List[langchain.callbacks.base.BaseCallbackHandler], langchain.callbacks.base.BaseCallbackManager]]) –
kwargs (Any) –
Return type
str
async agenerate(prompts, stop=None, callbac... | https://api.python.langchain.com/en/latest/modules/llms.html |
0e0436a883fe-581 | Take in a list of prompt values and return an LLMResult.
Parameters
prompts (List[langchain.schema.PromptValue]) –
stop (Optional[List[str]]) –
callbacks (Optional[Union[List[langchain.callbacks.base.BaseCallbackHandler], langchain.callbacks.base.BaseCallbackManager]]) –
kwargs (Any) –
Return type
langchain.schema.... | https://api.python.langchain.com/en/latest/modules/llms.html |
0e0436a883fe-582 | Return type
langchain.schema.BaseMessage
classmethod construct(_fields_set=None, **values)
Creates a new model setting __dict__ and __fields_set__ from trusted or pre-validated data.
Default values are respected, but no other validation is performed.
Behaves as if Config.extra = ‘allow’ was set since it adds all passe... | https://api.python.langchain.com/en/latest/modules/llms.html |
0e0436a883fe-583 | update (Optional[DictStrAny]) – values to change/add in the new model. Note: the data is not validated before creating
the new model: you should trust this data
deep (bool) – set to True to make a deep copy of the model
self (Model) –
Returns
new model instance
Return type
Model
dict(**kwargs)
Return a dictionary of ... | https://api.python.langchain.com/en/latest/modules/llms.html |
0e0436a883fe-584 | kwargs (Any) –
Return type
langchain.schema.LLMResult
generate_prompt(prompts, stop=None, callbacks=None, **kwargs)
Take in a list of prompt values and return an LLMResult.
Parameters
prompts (List[langchain.schema.PromptValue]) –
stop (Optional[List[str]]) –
callbacks (Optional[Union[List[langchain.callbacks.base.... | https://api.python.langchain.com/en/latest/modules/llms.html |
0e0436a883fe-585 | int
get_token_ids(text)
Get the token present in the text.
Parameters
text (str) –
Return type
List[int]
json(*, include=None, exclude=None, by_alias=False, skip_defaults=None, exclude_unset=False, exclude_defaults=False, exclude_none=False, encoder=None, models_as_dict=True, **dumps_kwargs)
Generate a JSON represen... | https://api.python.langchain.com/en/latest/modules/llms.html |
0e0436a883fe-586 | exclude_none (bool) –
encoder (Optional[Callable[[Any], Any]]) –
models_as_dict (bool) –
dumps_kwargs (Any) –
Return type
unicode
predict(text, *, stop=None, **kwargs)
Predict text from text.
Parameters
text (str) –
stop (Optional[Sequence[str]]) –
kwargs (Any) –
Return type
str
predict_messages(messages, *, st... | https://api.python.langchain.com/en/latest/modules/llms.html |
0e0436a883fe-587 | Return type
None
Example:
.. code-block:: python
llm.save(file_path=”path/llm.yaml”)
classmethod update_forward_refs(**localns)
Try to update ForwardRefs on fields based on this Model, globalns and localns.
Parameters
localns (Any) –
Return type
None
property lc_attributes: Dict
Return a list of attribute names that... | https://api.python.langchain.com/en/latest/modules/llms.html |
0e0436a883fe-588 | property lc_serializable: bool
Return whether or not the class is serializable.
class langchain.llms.VertexAI(*, cache=None, verbose=None, callbacks=None, callback_manager=None, tags=None, client=None, model_name='text-bison', temperature=0.0, max_output_tokens=128, top_p=0.95, top_k=40, stop=None, project=None, locat... | https://api.python.langchain.com/en/latest/modules/llms.html |
0e0436a883fe-589 | tags (Optional[List[str]]) –
client (_LanguageModel) –
model_name (str) –
temperature (float) –
max_output_tokens (int) –
top_p (float) –
top_k (int) –
stop (Optional[List[str]]) –
project (Optional[str]) –
location (str) –
credentials (Any) –
tuned_model_name (Optional[str]) –
Return type
None
attribute cr... | https://api.python.langchain.com/en/latest/modules/llms.html |
0e0436a883fe-590 | The name of the Vertex AI large language model.
attribute project: Optional[str] = None
The default GCP project to use when making Vertex API calls.
attribute stop: Optional[List[str]] = None
Optional list of stop words to use when generating.
attribute tags: Optional[List[str]] = None
Tags to add to the run trace.
... | https://api.python.langchain.com/en/latest/modules/llms.html |
0e0436a883fe-591 | attribute verbose: bool [Optional]
Whether to print out response text.
__call__(prompt, stop=None, callbacks=None, **kwargs)
Check Cache and run the LLM on the given prompt and input.
Parameters
prompt (str) –
stop (Optional[List[str]]) –
callbacks (Optional[Union[List[langchain.callbacks.base.BaseCallbackHandler],... | https://api.python.langchain.com/en/latest/modules/llms.html |
0e0436a883fe-592 | tags (Optional[List[str]]) –
kwargs (Any) –
Return type
langchain.schema.LLMResult
async agenerate_prompt(prompts, stop=None, callbacks=None, **kwargs)
Take in a list of prompt values and return an LLMResult.
Parameters
prompts (List[langchain.schema.PromptValue]) –
stop (Optional[List[str]]) –
callbacks (Optional... | https://api.python.langchain.com/en/latest/modules/llms.html |
0e0436a883fe-593 | Predict message from messages.
Parameters
messages (List[langchain.schema.BaseMessage]) –
stop (Optional[Sequence[str]]) –
kwargs (Any) –
Return type
langchain.schema.BaseMessage
classmethod construct(_fields_set=None, **values)
Creates a new model setting __dict__ and __fields_set__ from trusted or pre-validated d... | https://api.python.langchain.com/en/latest/modules/llms.html |
0e0436a883fe-594 | exclude (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) – fields to exclude from new model, as with values this takes precedence over include
update (Optional[DictStrAny]) – values to change/add in the new model. Note: the data is not validated before creating
the new model: you should trust this data
deep (bool... | https://api.python.langchain.com/en/latest/modules/llms.html |
0e0436a883fe-595 | stop (Optional[List[str]]) –
callbacks (Optional[Union[List[langchain.callbacks.base.BaseCallbackHandler], langchain.callbacks.base.BaseCallbackManager]]) –
tags (Optional[List[str]]) –
kwargs (Any) –
Return type
langchain.schema.LLMResult
generate_prompt(prompts, stop=None, callbacks=None, **kwargs)
Take in a lis... | https://api.python.langchain.com/en/latest/modules/llms.html |
0e0436a883fe-596 | Return type
int
get_num_tokens_from_messages(messages)
Get the number of tokens in the message.
Parameters
messages (List[langchain.schema.BaseMessage]) –
Return type
int
get_token_ids(text)
Get the token present in the text.
Parameters
text (str) –
Return type
List[int]
json(*, include=None, exclude=None, by_alias... | https://api.python.langchain.com/en/latest/modules/llms.html |
0e0436a883fe-597 | exclude (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) –
by_alias (bool) –
skip_defaults (Optional[bool]) –
exclude_unset (bool) –
exclude_defaults (bool) –
exclude_none (bool) –
encoder (Optional[Callable[[Any], Any]]) –
models_as_dict (bool) –
dumps_kwargs (Any) –
Return type
unicode
predict(text, *,... | https://api.python.langchain.com/en/latest/modules/llms.html |
0e0436a883fe-598 | kwargs (Any) –
Return type
langchain.schema.BaseMessage
save(file_path)
Save the LLM.
Parameters
file_path (Union[pathlib.Path, str]) – Path to file to save the LLM to.
Return type
None
Example:
.. code-block:: python
llm.save(file_path=”path/llm.yaml”)
classmethod update_forward_refs(**localns)
Try to update Forwar... | https://api.python.langchain.com/en/latest/modules/llms.html |
0e0436a883fe-599 | property lc_secrets: Dict[str, str]
Return a map of constructor argument names to secret ids.
eg. {“openai_api_key”: “OPENAI_API_KEY”}
property lc_serializable: bool
Return whether or not the class is serializable.
class langchain.llms.Writer(*, cache=None, verbose=None, callbacks=None, callback_manager=None, tags=No... | https://api.python.langchain.com/en/latest/modules/llms.html |
0e0436a883fe-600 | WRITER_ORG_ID set with your API key and organization ID respectively.
Example
from langchain import Writer
writer = Writer(model_id="palmyra-base")
Parameters
cache (Optional[bool]) –
verbose (bool) –
callbacks (Optional[Union[List[langchain.callbacks.base.BaseCallbackHandler], langchain.callbacks.base.BaseCallbackMa... | https://api.python.langchain.com/en/latest/modules/llms.html |
0e0436a883fe-601 | best_of (Optional[int]) –
logprobs (bool) –
n (Optional[int]) –
writer_api_key (Optional[str]) –
base_url (Optional[str]) –
Return type
None
attribute base_url: Optional[str] = None
Base url to use, if None decides based on model name.
attribute best_of: Optional[int] = None
Generates this many completions serve... | https://api.python.langchain.com/en/latest/modules/llms.html |
0e0436a883fe-602 | How many completions to generate.
attribute presence_penalty: Optional[float] = None
Penalizes repeated tokens regardless of frequency.
attribute repetition_penalty: Optional[float] = None
Penalizes repeated tokens according to frequency.
attribute stop: Optional[List[str]] = None
Sequences when completion generatio... | https://api.python.langchain.com/en/latest/modules/llms.html |
0e0436a883fe-603 | Writer organization ID.
__call__(prompt, stop=None, callbacks=None, **kwargs)
Check Cache and run the LLM on the given prompt and input.
Parameters
prompt (str) –
stop (Optional[List[str]]) –
callbacks (Optional[Union[List[langchain.callbacks.base.BaseCallbackHandler], langchain.callbacks.base.BaseCallbackManager]])... | https://api.python.langchain.com/en/latest/modules/llms.html |
0e0436a883fe-604 | Return type
langchain.schema.LLMResult
async agenerate_prompt(prompts, stop=None, callbacks=None, **kwargs)
Take in a list of prompt values and return an LLMResult.
Parameters
prompts (List[langchain.schema.PromptValue]) –
stop (Optional[List[str]]) –
callbacks (Optional[Union[List[langchain.callbacks.base.BaseCallb... | https://api.python.langchain.com/en/latest/modules/llms.html |
0e0436a883fe-605 | Predict message from messages.
Parameters
messages (List[langchain.schema.BaseMessage]) –
stop (Optional[Sequence[str]]) –
kwargs (Any) –
Return type
langchain.schema.BaseMessage
classmethod construct(_fields_set=None, **values)
Creates a new model setting __dict__ and __fields_set__ from trusted or pre-validated d... | https://api.python.langchain.com/en/latest/modules/llms.html |
0e0436a883fe-606 | exclude (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) – fields to exclude from new model, as with values this takes precedence over include
update (Optional[DictStrAny]) – values to change/add in the new model. Note: the data is not validated before creating
the new model: you should trust this data
deep (bool... | https://api.python.langchain.com/en/latest/modules/llms.html |
0e0436a883fe-607 | stop (Optional[List[str]]) –
callbacks (Optional[Union[List[langchain.callbacks.base.BaseCallbackHandler], langchain.callbacks.base.BaseCallbackManager]]) –
tags (Optional[List[str]]) –
kwargs (Any) –
Return type
langchain.schema.LLMResult
generate_prompt(prompts, stop=None, callbacks=None, **kwargs)
Take in a lis... | https://api.python.langchain.com/en/latest/modules/llms.html |
0e0436a883fe-608 | Return type
int
get_num_tokens_from_messages(messages)
Get the number of tokens in the message.
Parameters
messages (List[langchain.schema.BaseMessage]) –
Return type
int
get_token_ids(text)
Get the token present in the text.
Parameters
text (str) –
Return type
List[int]
json(*, include=None, exclude=None, by_alias... | https://api.python.langchain.com/en/latest/modules/llms.html |
0e0436a883fe-609 | exclude (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) –
by_alias (bool) –
skip_defaults (Optional[bool]) –
exclude_unset (bool) –
exclude_defaults (bool) –
exclude_none (bool) –
encoder (Optional[Callable[[Any], Any]]) –
models_as_dict (bool) –
dumps_kwargs (Any) –
Return type
unicode
predict(text, *,... | https://api.python.langchain.com/en/latest/modules/llms.html |
0e0436a883fe-610 | kwargs (Any) –
Return type
langchain.schema.BaseMessage
save(file_path)
Save the LLM.
Parameters
file_path (Union[pathlib.Path, str]) – Path to file to save the LLM to.
Return type
None
Example:
.. code-block:: python
llm.save(file_path=”path/llm.yaml”)
classmethod update_forward_refs(**localns)
Try to update Forwar... | https://api.python.langchain.com/en/latest/modules/llms.html |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.