Ollama soporta una variedad de LLMs incluyendo LLaMA-2, LLaMA sin censura, CodeLLaMA, Falcon, Mistral, Vicuna model, WizardCoder, y Wizard sin censura.
Empecemos:
Paso 1: Instala Ollama en tu PC usando: https://ollama.com/
Aquí puedes ver que hay varios modelos lingüísticos disponibles que puedes usar directamente en tu PC sin necesidad de GPU. (Pero debes tener al menos 16 GB de RAM para trabajar sin problemas en tu ordenador).
Paso 2: Después de la instalación, abre el terminal y ejecuta el siguiente comando (ollama). Debería mostrar exactamente la misma imagen si la instalación se ha hecho perfectamente:
Paso 3: Para comprobar qué modelos has descargado, ejecuta «ollama list». Si ya has descargado algún modelo, se mostrará el nombre del modelo; de lo contrario, ve al paso 4.
Paso 4: Ahora ejecuta el siguiente comando para descargar tu modelo si aún no lo has hecho.
ollama pull llama3
Esto descargará el Modelo llama3 y ahora ves al paso 3 y realiza dicho paso, verás tu «Lista de Modelos Descargados» por allí.
Paso 5: Ahora, aquí termina tu solución.
Abre tu IDE favorito o VS código según tu elección y ejecuta el código:
(Si has instalado todos los módulos necesarios)
from llama_index.llms.ollama import Ollama
llm = Ollama(model="llama3", request_timeout=120.0)
resp = llm.complete("Who is Paul Graham?")
print(resp)
Resultado: Aquí, lo que he recibido la Ouput ejecutando el Código:
Importante: Asegúrate de que el servidor Ollama está encendido, siempre que se está ejecutando el código (Ollama ejecutar llama3)
CompletionResponse(text="Paul Graham (1924-2011) was a British Anglican priest and missionary who served in Africa, particularly in Sudan and Uganda. He was known for his courageous work in the midst of conflict, violence, and humanitarian crises.\n\nGraham was born in England and trained as an Anglican priest. In 1957, he arrived in Sudan, which was then torn apart by civil war and rebellion. He spent over a decade serving as a missionary, providing spiritual guidance, medical aid, and emotional support to refugees, displaced people, and those affected by the conflict.\n\nIn Uganda, Graham worked with the Church of Uganda (the Anglican church in that country) from 1974 to 1982. During this period, he was instrumental in supporting the Ugandan church's efforts to provide relief and rehabilitation services to victims of war, including former child soldiers, orphans, and displaced people.\n\nGraham's work in Sudan and Uganda earned him international recognition for his bravery, compassion, and commitment to serving those affected by conflict and humanitarian crises. He was awarded the Order of the British Empire (OBE) in 1992 for his services to humanitarian work.\n\nPaul Graham's story has inspired many, particularly in the Anglican Communion, to pursue careers in humanitarian aid, mission, and international development. His legacy continues to be celebrated through various initiatives and organizations that build on his work and values of compassion, resilience, and faith.", additional_kwargs={'model': 'llama3', 'created_at': '2024-05-09T09:35:27.4392434Z', 'done': True, 'context': [128006, 882, 128007, 198, 198, 15546, 374, 7043, 26181, 30, 128009, 128006, 78191, 128007, 198, 198, 26368, 26181, 320, 777, 1187, 12, 679, 16, 8, 574, 264, 8013, 91634, 276, 28185, 323, 73998, 889, 10434, 304, 10384, 11, 8104, 304, 43554, 323, 58149, 13, 1283, 574, 3967, 369, 813, 75748, 990, 304, 279, 35446, 315, 12324, 11, 9349, 11, 323, 38748, 58187, 627, 198, 38, 17012, 574, 9405, 304, 9635, 323, 16572, 439, 459, 91634, 276, 28185, 13, 763, 220, 777, 3226, 11, 568, 11721, 304, 43554, 11, 902, 574, 1243, 21830, 10980, 555, 8431, 4208, 323, 53848, 13, 1283, 7543, 927, 264, 13515, 13788, 439, 264, 73998, 11, 8405, 18330, 19351, 11, 6593, 12576, 11, 323, 14604, 1862, 311, 22475, 11, 49246, 1274, 11, 323, 1884, 11754, 555, 279, 12324, 627, 198, 644, 58149, 11, 26181, 6575, 449, 279, 9441, 315, 58149, 320, 1820, 91634, 276, 8993, 304, 430, 3224, 8, 505, 220, 4468, 19, 311, 220, 3753, 17, 13, 12220, 420, 4261, 11, 568, 574, 42045, 304, 12899, 279, 47430, 83908, 8993, 596, 9045, 311, 3493, 16337, 323, 44438, 3600, 311, 12697, 315, 4208, 11, 2737, 4846, 1716, 15201, 11, 477, 85411, 11, 323, 49246, 1274, 627, 198, 38, 17012, 596, 990, 304, 43554, 323, 58149, 15662, 1461, 6625, 18324, 369, 813, 86166, 11, 30481, 11, 323, 15507, 311, 13788, 1884, 11754, 555, 12324, 323, 38748, 58187, 13, 1283, 574, 22034, 279, 7365, 315, 279, 8013, 21080, 320, 46, 11855, 8, 304, 220, 2550, 17, 369, 813, 3600, 311, 38748, 990, 627, 198, 26368, 26181, 596, 3446, 706, 14948, 1690, 11, 8104, 304, 279, 91634, 276, 6947, 16588, 11, 311, 23564, 31133, 304, 38748, 12576, 11, 9131, 11, 323, 6625, 4500, 13, 5414, 20160, 9731, 311, 387, 28284, 1555, 5370, 28271, 323, 11351, 430, 1977, 389, 813, 990, 323, 2819, 315, 30481, 11, 56062, 11, 323, 10082, 13, 128009], 'total_duration': 59851752500, 'load_duration': 5734008100, 'prompt_eval_count': 15, 'prompt_eval_duration': 1374706000, 'eval_count': 291, 'eval_duration': 52739686000}, raw={'model': 'llama3', 'created_at': '2024-05-09T09:35:27.4392434Z', 'response': "Paul Graham (1924-2011) was a British Anglican priest and missionary who served in Africa, particularly in Sudan and Uganda. He was known for his courageous work in the midst of conflict, violence, and humanitarian crises.\n\nGraham was born in England and trained as an Anglican priest. In 1957, he arrived in Sudan, which was then torn apart by civil war and rebellion. He spent over a decade serving as a missionary, providing spiritual guidance, medical aid, and emotional support to refugees, displaced people, and those affected by the conflict.\n\nIn Uganda, Graham worked with the Church of Uganda (the Anglican church in that country) from 1974 to 1982. During this period, he was instrumental in supporting the Ugandan church's efforts to provide relief and rehabilitation services to victims of war, including former child soldiers, orphans, and displaced people.\n\nGraham's work in Sudan and Uganda earned him international recognition for his bravery, compassion, and commitment to serving those affected by conflict and humanitarian crises. He was awarded the Order of the British Empire (OBE) in 1992 for his services to humanitarian work.\n\nPaul Graham's story has inspired many, particularly in the Anglican Communion, to pursue careers in humanitarian aid, mission, and international development. His legacy continues to be celebrated through various initiatives and organizations that build on his work and values of compassion, resilience, and faith.", 'done': True, 'context': [128006, 882, 128007, 198, 198, 15546, 374, 7043, 26181, 30, 128009, 128006, 78191, 128007, 198, 198, 26368, 26181, 320, 777, 1187, 12, 679, 16, 8, 574, 264, 8013, 91634, 276, 28185, 323, 73998, 889, 10434, 304, 10384, 11, 8104, 304, 43554, 323, 58149, 13, 1283, 574, 3967, 369, 813, 75748, 990, 304, 279, 35446, 315, 12324, 11, 9349, 11, 323, 38748, 58187, 627, 198, 38, 17012, 574, 9405, 304, 9635, 323, 16572, 439, 459, 91634, 276, 28185, 13, 763, 220, 777, 3226, 11, 568, 11721, 304, 43554, 11, 902, 574, 1243, 21830, 10980, 555, 8431, 4208, 323, 53848, 13, 1283, 7543, 927, 264, 13515, 13788, 439, 264, 73998, 11, 8405, 18330, 19351, 11, 6593, 12576, 11, 323, 14604, 1862, 311, 22475, 11, 49246, 1274, 11, 323, 1884, 11754, 555, 279, 12324, 627, 198, 644, 58149, 11, 26181, 6575, 449, 279, 9441, 315, 58149, 320, 1820, 91634, 276, 8993, 304, 430, 3224, 8, 505, 220, 4468, 19, 311, 220, 3753, 17, 13, 12220, 420, 4261, 11, 568, 574, 42045, 304, 12899, 279, 47430, 83908, 8993, 596, 9045, 311, 3493, 16337, 323, 44438, 3600, 311, 12697, 315, 4208, 11, 2737, 4846, 1716, 15201, 11, 477, 85411, 11, 323, 49246, 1274, 627, 198, 38, 17012, 596, 990, 304, 43554, 323, 58149, 15662, 1461, 6625, 18324, 369, 813, 86166, 11, 30481, 11, 323, 15507, 311, 13788, 1884, 11754, 555, 12324, 323, 38748, 58187, 13, 1283, 574, 22034, 279, 7365, 315, 279, 8013, 21080, 320, 46, 11855, 8, 304, 220, 2550, 17, 369, 813, 3600, 311, 38748, 990, 627, 198, 26368, 26181, 596, 3446, 706, 14948, 1690, 11, 8104, 304, 279, 91634, 276, 6947, 16588, 11, 311, 23564, 31133, 304, 38748, 12576, 11, 9131, 11, 323, 6625, 4500, 13, 5414, 20160, 9731, 311, 387, 28284, 1555, 5370, 28271, 323, 11351, 430, 1977, 389, 813, 990, 323, 2819, 315, 30481, 11, 56062, 11, 323, 10082, 13, 128009], 'total_duration': 59851752500, 'load_duration': 5734008100, 'prompt_eval_count': 15, 'prompt_eval_duration': 1374706000, 'eval_count': 291, 'eval_duration': 52739686000}, logprobs=None, delta=None)
Házlo tú mismo (DIY): Descarga ahora el modelo «phi3» y comprueba cuál funciona mejor en tu caso de uso.
Sorpresa: Si no tienes suficiente espacio y quieres ejecutar esto en tu Google Collab, a continuación, lee este BLOG.