Consituyen una serie de modelos del lenguaje desarrollados por OpenAI. Estos modelos son conocidos por su capacidad para generar texto, responder preguntas, traducir idiomas, resumir documentos y realizar una variedad de otras tareas lingüísticas. La arquitectura de GPT se basa en el concepto de Transformer.
from ctransformers import AutoModelForCausalLM
llm = AutoModelForCausalLM.from_pretrained("TheBloke/Mistral-7B-Instruct-v0.1-GGUF", model_file="mistral-7b-instruct-v0.1.Q5_K_M.gguf", model_type="mistral", gpu_layers=50)
Fetching 1 files: 0%| | 0/1 [00:00<?, ?it/s]
Fetching 1 files: 0%| | 0/1 [00:00<?, ?it/s]
print(llm("¿Si tengo 15 manzanas y me como 3, cuántas me quedan?"))
Answer: 12 manzanas
Descarga e instala LM Studio desde aquí.
import os
import openai
openai.api_base = "http://localhost:1234/v1" # point to the local server
openai.api_key = "" # no need for an API key
completion = openai.ChatCompletion.create(
model="local-model", # this field is currently unused
messages=[
{"role": "system", "content": "You are an assistant helping a student with their homework"},
{"role": "assistant", "content": "Hi, how can I help you today?"},
{"role": "user", "content": "I need help with my chemistry homework. Can you help me?"},
{"role": "assistant", "content": "Of course! What specific topic or problem are you working on? Please provide more details so I can better assist you."},
{"role": "user", "content": "Do you know how to formulate oxides?"},
]
)
print(completion.choices[0].message)
{ "role": "assistant", "content": "Yes, I'm happy to help!\n\nFormulating oxides involves combining oxygen atoms with other elements to create compounds. There are several types of oxides that can be formed depending on the element being oxidized and the amount of oxygen added. Here are a few common examples:\n\n1. Simple Oxides: These are formed by adding one oxygen atom to an element. For example, carbon (C) combined with oxygen (O2) forms carbon dioxide (CO2), and hydrogen (H) combined with oxygen (O2) forms water (H2O).\n2. Compound Oxides: These are formed by combining two or more elements with oxygen. For example, the oxide of nitrogen (N2) and oxygen (O2) is called nitrogen dioxide (NO2), and the oxide of sulfur (S) and oxygen (O2) is called sulfur dioxide (SO2).\n3. Peroxides: These are formed by adding two oxygen atoms to an element, which results in a molecule with one hydrogen bond between the two oxygen atoms. For example, the peroxide of hydrogen (H2O2) and oxygen (O2) is called hydrogen peroxide (H2O2), and the peroxide of manganese (Mn2O4) and oxygen (O2) is called manganese dioxide (Mn2O4).\n\nI hope this helps! Let me know if you have any further questions." }
print(completion.choices[0].message["content"])
Yes, I'm happy to help! Formulating oxides involves combining oxygen atoms with other elements to create compounds. There are several types of oxides that can be formed depending on the element being oxidized and the amount of oxygen added. Here are a few common examples: 1. Simple Oxides: These are formed by adding one oxygen atom to an element. For example, carbon (C) combined with oxygen (O2) forms carbon dioxide (CO2), and hydrogen (H) combined with oxygen (O2) forms water (H2O). 2. Compound Oxides: These are formed by combining two or more elements with oxygen. For example, the oxide of nitrogen (N2) and oxygen (O2) is called nitrogen dioxide (NO2), and the oxide of sulfur (S) and oxygen (O2) is called sulfur dioxide (SO2). 3. Peroxides: These are formed by adding two oxygen atoms to an element, which results in a molecule with one hydrogen bond between the two oxygen atoms. For example, the peroxide of hydrogen (H2O2) and oxygen (O2) is called hydrogen peroxide (H2O2), and the peroxide of manganese (Mn2O4) and oxygen (O2) is called manganese dioxide (Mn2O4). I hope this helps! Let me know if you have any further questions.