Deepseek De Cero | A Experto- Desde Instalacion A Produccion -mega-
Luego desde tu app:
documento_completo = open("manual_largo.txt").read()[:950000] # 950k tokens response = client.chat.completions.create( model="deepseek-chat", messages=[ {"role": "system", "content": "Responde usando solo la información del siguiente documento:"}, {"role": "user", "content": f"Documento: {documento_completo}\n\nPregunta: ¿Cuál es el procedimiento de emergencia?"} ], max_tokens=2000 ) 5.1 Servicio con vLLM (Máximo rendimiento) vLLM es el servidor estándar para LLMs en producción.
response = client.chat.completions.create( model="deepseek-chat", # Modelo optimizado para conversación messages=[ {"role": "system", "content": "Eres un experto en DevOps y sistemas distribuidos."}, {"role": "user", "content": "Escribe un Dockerfile para un servicio FastAPI con dependencias de ML."} ], temperature=0.7, max_tokens=1024 ) Usa super() para MRO
functions = [ { "name": "obtener_clima", "description": "Obtiene temperatura actual de una ciudad", "parameters": { "type": "object", "properties": { "ciudad": {"type": "string", "description": "Nombre de la ciudad"} }, "required": ["ciudad"] } } ] response = client.chat.completions.create( model="deepseek-chat", messages=[{"role": "user", "content": "¿Qué tiempo hace en Madrid?"}], functions=functions, function_call="auto" ) Capítulo 3: Fine-Tuning Profesional (Nivel Avanzado) DeepSeek es excelente para fine-tuning en tareas específicas (código, matemáticas, dominios médicos). 3.1 Preparación del Dataset (Formato ChatML) {"messages": [{"role": "user", "content": "¿Cómo invertir una lista en Python?"}, {"role": "assistant", "content": "Usa reversed(lista) o lista[::-1]"}]} {"messages": [{"role": "user", "content": "Explica herencia múltiple en Python."}, {"role": "assistant", "content": "Python permite herencia múltiple, pero puede causar el problema del diamante. Usa super() para MRO."}]} 3.2 Fine-Tuning con LoRA (Eficiente en memoria) Usando la biblioteca peft y trl :
respuesta = qa_chain("¿Cómo configurar el parámetro X en el sistema?") print(respuesta["result"]) Para documentos masivos, puedes inyectar todo el contexto directamente: messages=[ {"role": "system"
# Instalar vLLM pip install vllm python -m vllm.entrypoints.openai.api_server --model deepseek-ai/deepseek-llm-7b-chat --tensor-parallel-size 1 --max-num-batched-tokens 4096 --port 8000
client = OpenAI(base_url="http://localhost:8000/v1", api_key="EMPTY") Dockerfile : "parameters": { "type": "object"
# Crear entorno virtual python -m venv deepseek-env source deepseek-env/bin/activate # Linux/Mac # deepseek-env\Scripts\activate # Windows pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118 # CUDA 11.8 pip install transformers accelerate bitsandbytes sentencepiece protobuf pip install vllm # Para inferencia en producción local 1.3 Carga del Modelo (Versión Cuantizada para Hardware Limitado) from transformers import AutoModelForCausalLM, AutoTokenizer import torch model_name = "deepseek-ai/deepseek-llm-7b-chat" # Modelo conversacional Carga con cuantización de 4 bits (requiere bitsandbytes) tokenizer = AutoTokenizer.from_pretrained(model_name, trust_remote_code=True) model = AutoModelForCausalLM.from_pretrained( model_name, device_map="auto", torch_dtype=torch.float16, load_in_4bit=True, # Reduce VRAM a ~6GB trust_remote_code=True ) Prueba de generación prompt = "Explica la diferencia entre un transformer encoder y decoder en inteligencia artificial." inputs = tokenizer(prompt, return_tensors="pt").to("cuda") outputs = model.generate(**inputs, max_new_tokens=200) print(tokenizer.decode(outputs[0], skip_special_tokens=True))
Comments 11
These are amazing. Thank you!
Nice man! Forgot about us mate! 🙂
That movie TV package is dope bro! Cheers!
Author
You’re welcome, it’s a massive list so glad you found something cool.
Thanks brotha. You’re hella dope for doing all this. Thank you!
You are just amazing. Checked all contents of your site . Just bookmarked your site on my mind trisamples.com. Very very thank you. I always wanted those bollywood music beats, found it here very very thanks.
With Love India
Author
Thank you for leaving some love appreciated.
Very nice. Really appreciate the effort you put in!
Wow, respect for all this work! This list is incredible. I admire people who make such a bother for others they do not even know! A thousand thanks and the best wishes for the new year … and all the following! 🙂
Best regards from Germany,
Tom (director and musician)
4W Filmproduction
cool thx
Hi! many thanks for the useful recompilation, I´d wish to share with you an honest music instruments . I hope assist you to seek out Good Music instrument