Python Daily
2.57K subscribers
1.48K photos
53 videos
2 files
38.9K links
Daily Python News
Question, Tips and Tricks, Best Practices on Python Programming Language
Find more reddit channels over at @r_channels
Download Telegram
R Foundation Model Alignment with RAFT🛶 in LMFlow

​

https://reddit.com/link/12pnwp8/video/bj5ks4001hua1/player

## Introduction

General-purpose foundation models, especially large language models (LLMs) such as ChatGPT, have demonstrated extraordinary capabilities in performing various tasks that were once challenging. However, we believe that one model cannot rule them all. Further fine-tuning is necessary to achieve better performance in specialized tasks or domains. The standard approaches for fine-tuning these models include:

Continuous pretraining on specific domains so that LLMs can acquire knowledge in those domains
Task tuning on specific tasks so that LLMs can deal with downstream tasks
Instruction tuning to endow LLMs the ability to comply with specialized natural language instructions and complete tasks required by those instructions
Alignment tuning to teach LLMs conversational skills in accordance with human preferences.

Alignment, in particular, is crucial for ensuring the safety of LLMs before deployment in the real world. Today we introduce a new alignment algorithm RAFT [1\] which is more effective than traditional methods such as PPO. RAFT mitigates the issue of bias that could emerge in LLM responses. Using RAFT for aligning LLMs offers numerous benefits, including the ability to disentangle unwanted biases from the LLM's language production while maintaining fluency levels consistently.

Check out the paper https://arxiv.org/abs/2304.06767.

Its implementation is available from https://github.com/OptimalScale/LMFlow.

## RAFT Alignment

Alignment is

/r/MachineLearning
https://redd.it/12pnwp8
Tuesday Daily Thread: Advanced questions

Have some burning questions on advanced Python topics? Use this thread to ask more advanced questions related to Python.

If your question is a beginner question we hold a beginner Daily Thread tomorrow (Wednesday) where you can ask any question! We may remove questions here and ask you to resubmit tomorrow.

This thread may be fairly low volume in replies, if you don't receive a response we recommend looking at r/LearnPython or joining the Python Discord server at https://discord.gg/python where you stand a better chance of receiving a response.

/r/Python
https://redd.it/12q2gyd
What do you use for encrypting data at rest?

Aside from password hashes.

What libraries do you use?

Directly in a model?

Do you monitor the overhead of encryption?

What do you choose not to encrypt?

/r/flask
https://redd.it/12qasa7
Issues with @login_required in Movie Watchlist app

With all the heavy lifting being done by chatgpt, I am confident the outputted code is trash but it's a proof of concept, I am trying to make a simple movie watchlist app.

The general idea is to query a DB I have full of all the titles available to stream at the moment, and a column that designates what provider it is on. User registers and states the services they pay for, Netflix for example, and they are shown a list of all the titles on Netflix. They click like and I save their 'likes' or dislike and they are shown the next title.

So far I have a working database connection. registering and login are working, as is the dashboard page showing their user details. But when I try and add the base functionality, showing them titles to like or dislike, I'm getting into trouble. Firstly they need to be logged in, I need to query the User database table to extract what services they have subscribed to and filter this list by provider.

This is where I run into issues and the all-knowing chatgpt is putting me into circles.

​

Here is the current "working" code minus the

/r/flask
https://redd.it/12qh84r
How does collectstatic work for sites that are constantly updated

Let's say I have a blog in production that I'm hosting with cPanel. If I publish a new blogpost that has new images, will I need to run the collectstatic command each time?

/r/django
https://redd.it/12q9f0e
For stock trading/finance, which kind of Python library are you looking for and can’t find?

Note : if you have time, you can put your not perfect but tentative solution url or its name

/r/Python
https://redd.it/12qfd3z
I’m developing a programming game where you use Python to automate all kinds of machines, robots, drones and more and solve exciting bite-sized coding challenges. (playtesting now)

Earlier this year, I first announced JOY OF PROGRAMMING here on r/python and it was met with an overwhelmingly positive reception. Your interest and support really mean a lot! In case you missed it, the game is all about using Python to solve challenging tasks in realistic, physically simulated 3D environments. It covers a wide range of topics, and hopefully presents interesting challenges and fun for all skill levels.

If you are interested in the game, you can find a lot more information on the Steam page.

https://store.steampowered.com/app/2216770/JOY\_OF\_PROGRAMMING\_\_Software\_Engineering\_Simulator

Today, I’d also like to invite you all to finally try an early version of the game! This alpha version focuses mainly on the beginner tutorials (6 at the moment) with one advanced level. Your feedback how difficult, engaging and ultimately fun the game and these levels are would be invaluable. I’m running this playtest on a newly created Discord server to make providing feedback and fixing bugs as seamless as possible. Please find the download link and all further details on Discord.

https://discord.com/invite/2ZrdzkNeBP

Happy Coding!

/r/Python
https://redd.it/12qn0ku
Kangas V2: Explore multimedia data

Project: [https://github.com/comet-ml/kangas](https://github.com/comet-ml/kangas)

Demo: [https://kangas.comet.com/](https://kangas.comet.com/)

​

We've just released version 2 of Kangas, our open source platform for exploring large, multimedia datasets. At a high-level, Kangas provides:

* A Python interface for constructing large tables of multimedia data (DataGrids), which should be very familiar to any Pandas users.
* A backend built on SQLLite and Flask for storing/querying/serving DataGrids.
* A UI built on React Server Components with Next 13 that enables fast, interactive exploration of your data

https://i.redd.it/ldpbbkb70nua1.gif

Kangas provides out of the box support for complex querying operations, as well as a variety of computer vision functionality (bounding boxes, labels, annotations, etc.) Additionally, the UI is customizable—you can resize, filter, and reorder columns as you like.

You can run Kangas from within a notebook, as a local app via the Kangas CLI, or even deploy it as a standalone web application (as we've done at [https://kangas.comet.com](https://kangas.comet.com))

Finally, I want to include a thank you here. About 5 months ago, I shared Kangas' initial V1 release here in r/Python, and several of you made your way over to the repo to share feedback and support. This was massively helpful for us. It helped us figure out what to prioritize, and opened our eyes to new features we hadn't considered.

/r/Python
https://redd.it/12qlmup
Using React with Django

My Django app is now becoming bigger, and the front end part (in vanilla JS) becomes pretty unmaintainable. I would like to change the front end to React, since it is component based and so it is more organized. It also has a dedicated testing framework for front-end use (unlike vanilla JS), and so I can ensure my front-end logic is robust. Does anyone ever done migration from Vanilla JS to React? How would the Django template work there? Does it work the same, and if so was it hard to write tests for them?

/r/django
https://redd.it/12qqxrv
Restrict access unless user is on a certain domain?

I’ve been asking a lot of questions recently. I’m getting ready to deploy my Django site soon. However, to ensure there’s further security. I only want it to be accessible to users on a certain domain. Meaning, once they are connected to a certain VPN domain. *.mydomain.com, access is allowed and user can log in. If they aren’t on that domain, they aren’t able to view or log in.

/r/djangolearning
https://redd.it/12r2gjt
Wednesday Daily Thread: Beginner questions

New to Python and have questions? Use this thread to ask anything about Python, there are no bad questions!

This thread may be fairly low volume in replies, if you don't receive a response we recommend looking at r/LearnPython or joining the Python Discord server at https://discord.gg/python where you stand a better chance of receiving a response.

/r/Python
https://redd.it/12r9j0k
Websocket connection failed & Not Found: /ws/home/room

new to django-channels and websockets in python and have been struggling with a big project, I can't figure out why I keep getting the errors in the title I even created a new project and followed a youtube tutorial step by step and still get the error

\- the main difference between mine and his is that my user flow goes through three pages -> login to home to the room- I also didn't initialize a virtual environment for my django project (don't think that matters)

from inspection i get websocket connection not found 'ws:// {localhost}/ws/home/room' and from project console i get Not Found: /ws/home/roomI'm trying to learn as I go about websockets and everything but have been struggling with this issue for a while now (a couple days lol)

heres my code:

[urls.py](https://urls.py)

`urlpatterns = [path('', views.login, name='login'),path('home/', views.home, name='home'),path('home/<str:room_name>/', views.room, name='room'),]`

[routing.py](https://routing.py)

`websocket_urlpatterns = [re_path(r'^ws/home/(?P<room_name>\w+)/$', consumers.GameConsumer),]`

[consumers.py](https://consumers.py)

`class GameConsumer(AsyncWebsocketConsumer):def __init__(self, *args, **kwargs):super().__init__(args, kwargs)self.room_name = Noneself.room_group_name = Noneasync def connect(self):self.room_name = self.scope['url_route']['kwargs']['room_name']self.room_group_name = '_%s' % self.room_name # unsure about 'game_%s'''' create new group '''await self.channel_layer.group_add(self.room_group_name,self.channel_name,)`

`await self.accept()`

`await self.channel_layer.group_send(self.room_group_name,{'type': 'tester_message','tester': 'hello world',})`

`async def tester_message(self, event):tester = event['tester']`

`await self.send(text_data=json.dumps({'tester': tester}))`

`async def disconnect(self, close_code):await self.channel_layer.group_discard(self.room_group_name,self.channel_name,)`

and heres where i create the websocket connection

`{{ room_name|json_script:"room-name" }}<script>const roomName = JSON.parse(document.getElementById('room-name').textContent)const socket = new WebSocket('ws://' +window.location.host

/r/djangolearning
https://redd.it/12r4wnx
Astral, the company behind Ruff

https://astral.sh/blog/announcing-astral-the-company-behind-ruff

I am not Charlie Marsh, so this isn't my blog. But I found the premise and the news very interesting and exciting!

ruff has become a can't-live-without tool very quickly, and I'm excited to see what comes out of Astral next

/r/Python
https://redd.it/12r7oi0
Handling Security of Encrypted Data

I want to make an application that is related to crypto. The user would enter a password, that would decrypt a crypto wallet key that is stored in a SQL database, and allow them to use this wallet to run transactions.

I do not want them to enter it for every action, I want to store the decrypted wallet key/the password (ill refer to either as the key) somewhere so it is a smooth interaction. I am curious about the security ethics around this. Where would I store the key, in browser cookies on the client side? If so, how secure is this, and how secure is sending the key back and forth via POSTS to the backend server?

/r/flask
https://redd.it/12r96bd
Dockerized Django with Postgres, Gunicorn, and Traefik (with Let's Encrypt)

Hey fellow Django enthusiasts!

I've created a cool project template that you can use as a foundation for your future projects by simply copying it: https://github.com/amerkurev/django-docker-template

The main idea is to solve all deployment-related issues at the initial stage. In this project, everything is built in Docker, launched with Docker Compose, and Let's Encrypt certificate is automatically issued (you just need to have a domain). The certificate is also automatically renewed. It is configured through environment variables and described how to work in development mode and how to deploy to production.

But the most important thing is the minimalism of this project. It has nothing extra, it's easy to extend or modify.

Personally, I now use it everywhere I need to quickly deploy a Django website. And it only takes me a couple of minutes to deploy everything in the cloud. Then I just write my Django applications.

&#x200B;

I would be very happy if you want to support the project with a PR, an interesting idea, or find bugs and write about it in the issue. Or at least give the project a star :)

I really love Django and value the Django community because it's a really cool product and cool people!

/r/django
https://redd.it/12r59gh
Sample flash app can't be accessed by other device in the local network with host="0.0.0.0" & turned off firewall

I created a simple flash app as followings ...

\---------------

from flask import Flask
app = Flask(__name__)


@ app.route("/")
def hello():
return "Hello World!"
if __name__ == "__main__":

app.run(host="0.0.0.0")

\---------------

Running the same flask app on both Windows machine#1 (M1) and Windows Machine#2 (M2). M2 can access to M1. No issue. However, the other way around didn't work.

\-- M2 is running flask app with host="0.0.0.0." and turned off firewall from McAfee

\-- M1 can't access the M2 flask app by ip address (192.168.0.111)

\>>> http://192.168.0.111:5000

Any ideas how to troubleshoot this?

/r/flask
https://redd.it/12r6eao