Implmentation for TMLR paper: Retiring ΔDP: New Distribution-Level Metrics for Demographic Parity, [Openreview], [Arxiv], by Xiaotian Han*, Zhimeng Jiang*, Hongye Jin*, Zirui Liu, Na Zou, Qifan Wang, Xia Hu
1. Introduction
Lots of fairness definitions (e.g., demographic parity, equalized opportunity) has been proposed to solve different types of fairness issues. In this paper, we focus on the measurement of demographic parity, $\Delta DP$, which requires the predictions of a machine learning model should be independent on sensitive attributes.
1.1 Drawbacks of commonly used $\Delta DP$
In this paper, we rethink the rationale of $\Delta DP$ and investigate its limitations on measuring the violation of demographic parity. There are two commonly used implementations of $\Delta DP$, including $\Delta DP_c$ (i.e., the difference of the mean of the predictive probabilities between different groups, and $\Delta DP_b$ (i.e., the difference of the proportion of positive prediction between different groups. We argue that $\Delta DP$, as a metric, has the following drawbacks:
Zero-value $\Delta DP$ does not guarantee zero violation of demographic parity.
$\Delta DP$ value is highly correlated to the selection of the threshold for the classification task.
1.2 The Proposed ABPC & ABCC
We propose two distribution-level metrics, namely Area Between Probability density function Curves (ABPC) and Area Between Cumulative density function Curves (ABCC), to retire $\Delta DP_{c}$ and $\Delta DP_{b}$ as follows:
Please kindly cite the following paper if you found our code helpful!
@article{han2023retiring,
title={Retiring $$\backslash$Delta $ DP: New Distribution-Level Metrics for Demographic Parity},
author={Han, Xiaotian and Jiang, Zhimeng and Jin, Hongye and Liu, Zirui and Zou, Na and Wang, Qifan and Hu, Xia},
journal={arXiv preprint arXiv:2301.13443},
year={2023}
}
4. Credit
We use Github Copilot to generate some comments in important code.
You can require pitchfork and use it inside of any Node.JS application.
varp4k=require('pitchfork')
Search
A Search constructor that extends EventEmitter. Listeners can be attached to the ‘ready’ event which will fire when all reviews have been fetched and parsed. For example:
Called once when Search is instantiated to fetch results. Not usually called directly
Page
A Page constructor that extends EventEmitter. This constructor takes an integer argument specifying which page of reviews you wish to fetch from /reviews/albums/:page_num. Listeners can be attached to the ‘ready’ event which will fire when all reviews have been fetched and parsed. For example, this would return all the most recent reviews:
The Review constructor encapsulates methods and data relating to the Pitchfork review. The Review extends EventEmitter and fires a ‘ready’ event when the review has been fetched and parsed.
.attributes
An Object with information about the album and its text. Sample below:
{
"url": "/reviews/albums/9419-the-letting-go/",
"name": "Bonnie \"Prince\" Billy - The Letting Go",
"artist": "Bonnie \"Prince\" Billy",
"album": "The Letting Go",
"title": "Bonnie \"Prince\" Billy: The Letting Go | Album Reviews | Pitchfork",
"label": "Palace / Drag City",
"year": "2006",
"score": 8.2,
"cover": "http://cdn.pitchfork.com/albums/9255/homepage_large.e8a2bd20.jpg",
"author": "Mark Richardson",
"date": "September 18, 2006",
"editorial": {
"text": "...",
"html": "..."
}
.fetch()
This method is automatically called when the Review is instantiated and returns a Promise. This generally isn’t called directly.
.promise
This stores the thennable promise object generated by .fetch for attaching .then-style callbacks.
.verbose()
The full Review instance represented as JSON.
{
"url": "/reviews/albums/9419-the-letting-go/",
"name": "Bonnie \"Prince\" Billy - The Letting Go",
"artist": "Bonnie \"Prince\" Billy",
"album": "The Letting Go",
"title": "Bonnie \"Prince\" Billy: The Letting Go | Album Reviews | Pitchfork",
"label": "Palace / Drag City",
"year": "2006",
"score": 8.2,
"cover": "http://cdn.pitchfork.com/albums/9255/homepage_large.e8a2bd20.jpg",
"author": "Mark Richardson",
"date": "September 18, 2006",
"editorial": {
"html": " <p>Though Will Oldham began his musical career while in his early twenties, ... deep absorption or self-reflection so much as a kind of fond familiarity. </p> ",
"text": " Though Will Oldham began his musical career while in his early twenties ... deep absorption or self-reflection so much as a kind of fond familiarity. "
}
}
.truncated()
The attributes of the Review instance with editorial.html/editorial.text condensed into the first 300 characters of of the text assigned to the key ‘.text’.
{
"url": "/reviews/albums/9419-the-letting-go/",
"name": "Bonnie \"Prince\" Billy - The Letting Go",
"artist": "Bonnie \"Prince\" Billy",
"album": "The Letting Go",
"title": "Bonnie \"Prince\" Billy: The Letting Go | Album Reviews | Pitchfork",
"label": "Palace / Drag City",
"year": "2006",
"score": 8.2,
"cover": "http://cdn.pitchfork.com/albums/9255/homepage_large.e8a2bd20.jpg",
"author": "Mark Richardson",
"date": "September 18, 2006",
"text": " Though Will Oldham began his musical career while in his early twenties, he's never exactly sounded young. From his first releases as Palace Music, Oldham's whiskey-soaked vocals and lyrical obsessions with death, sex, and religion have made \"maturity\" something of a non-issue. And yet, with his mo..."
}
.text_pretty_print()
Prints a plain-text representation of the review.
CLI (Command-Line Interface)
Returns a review for a given artist and album title.
Recipe for a self-contained script to look up OUIs.
Simply:
make
This will create a oui-lookup.sh script. The script comes with a greppable OUI
database appended to itself and requires no external dependencies to run, aside
from standard Unix utilities.
To generate the script and also install it locally as oui-lookup:
make install # will install at ~/.local/bin
To choose a custom install prefix:
PREFIX=/usr/local make install # will install at /usr/local/bin
Usage
To search for a prefix, use hexadecimal notation. Regexps are not accepted.
% oui-lookup 001122
001122 CIMSYS Inc
The prefix needs not be 3 octets long. It can be shorter, which will match many
entries. Or it can be longer, so you can mindlessly pass full addresses.
# Full address search.
% oui-lookup 001122334455
001122 CIMSYS Inc
# Shorter prefix search.
% oui-lookup 001 | sort | head
001000 CABLE TELEVISION LABORATORIES, INC.
001001 Citel
001002 ACTIA
001003 IMATRON, INC.
001004 THE BRANTLEY COILE COMPANY,INC
001005 UEC COMMERCIAL
001006 Thales Contact Solutions Ltd.
001007 Cisco Systems, Inc
001008 VIENNA SYSTEMS CORPORATION
001009 HORANET
The format accepts common separators between any two octets.
Would You Rather is a Questionnaire App that allows you to ask and answer questions about what you rather between only two options, you can answer your own question or any other user’s question, add and ask a new question to other users, also you can access the leaderboard page to see the active state of the users according to their score.
- 1- Fork, clone or download this repository to your local machine.
- 2- Be sure that you install the Node.js environment in your machine.
- 3- Open your terminal and be sure that you are inside the correct destination of the App, while you must be in the same path of the package.json file.
- 4- Inside your terminal run these commands:-
* to install dependencies.
```
npm install
```
* to start the server.
```
npm start
```
- 5- Once the App server is running, visit (localhost:3000) in the browser to view the App and now you can treat with it as shown above in the Demo.
- 6- You can also see a live preview of the App from this Link (https://would-you-rather14.netlify.app/)
The App depends on a fake static database, using customized methods to send requests and get questions from this database.
You have the ability to login with the option of 3 users in the login form, and you have to choose one user to be able to access the internal pages of the App.
The App contains of 404 page which will be rendered if the user tries to access a not available page.
Due to dealing with fake static database, so if you try to reload the App at any time, your progress in the App about adding or answering questions will be lost, and the data will be reset to its initial state.
The _DATA.js file represents the fake static database and the methods that let you access this database.
There are two types of objects stored in the fake static database: [Questions & Users]
The App contacts with the database via 4 methods:
_getUsers()
_getQuestions()
_saveQuestion(question)
_saveQuestionAnswer(object)
_getUsers() Method:
Description: Get all of the existing users from the database. Return Value: Object where the key is the user’s id and the value is the user object.
_getQuestions() Method:
Description: Get all of the existing questions from the database. Return Value: Object where the key is the question’s id and the value is the question object.
_saveQuestion(question) Method:
Description: Save the polling question in the database. Parameters: Object that includes the following properties: author, optionOneText, and optionTwoText.
Return Value: An object that has the following properties: id, author, optionOne, optionTwo, timestamp.
_saveQuestionAnswer(object) Method:
Description: Save the answer to a particular polling question in the database.
Parameters: Object that contains the following properties: authedUser, qid, and answer.
Finally, you can consider this App as a reference and strong practical & revision to understand the working logic of redux, react-redux & middleware like redux-thunk and how they interact with a react App.
This project took inspiration from the VSCode extension Conflict Squeezer.
Over the years working with Git, I’ve had to resolve many merge conflicts. When I used VSCode, the Conflict Squeezer extension saved me a lot of time on the more challenging merge conflicts. After moving on to Neovim, I started missing this functionality so much that I decided to rewrite it. One late night later and a bit less hair on my head, here it is!
Features
This plugin creates a command called ConflictJuggler that:
Scans the current buffer and removes the conflict markers when both sides of the conflict are the same.
Simplifies the conflict when the start or the end are the same, moving the matching lines out of the block.
Supports nested conflict markers (WOW! 🤩)
Installation
You can install this plugin with the plugin manager of your choice. Here are a few examples:
Lazy
{ 'pv-hernandez/conflict-juggler.nvim' }
Plug
Plug 'pv-hernandez/conflict-juggler.nvim'
Usage
To use this plugin you just need to run the command :ConflictJuggler on a buffer with conflict markers. The conflict block will get simplified.
The conflict below:
<<<<<<< HEAD
aaa
bbb
=======
bbb
>>>>>>> remote
Becomes:
<<<<<<< HEAD
aaa
=======
>>>>>>> remote
bbb
The strategy is to make both sides of the conflict match so that the lines get moved by the plugin. So say we want the final file to have the “aaa” line. We add that line to the “remote” part of the conflict:
<<<<<<< HEAD
aaa
=======
aaa
>>>>>>> remote
bbb
And run the command again:
aaa
bbb
This is a small example but it get really useful when the conflict blocks span tens or hundreds of lines, most of them are the same with indentation changes or some other small change that is hard to spot quickly.
Real world example
A Flutter project is an example of code base where this kind of conflict happens frequently, because of the amount of nested objects you create. In this example one change added a Theme around the widget tree, and another change added a Column around the widget tree. The entire tree got indented by a different amount in each change, so the conflict block spans the entire build method:
It is difficult to know if there are more changes in the middle of the widget tree by just looking at the conflict block, so we make the start and the end of the changes the same and run the command :ConflictJuggler:
The conflict makers move closer together, around one part of the widget tree that is different between both sides. Now you can keep making both sides match and running the command until the conflict is gone.
This process avoids missing on small changes in the middle of the conflict block.
If you like this plugin, don’t forget to share it with others!
[6/3] 🔥 All training (llava-1.5-m3) and evaluations (llava-1.5-m3 and llava-next-m3) code are release.
[5/27] 🔥 We released Matryoshka Multimodal Models. We propose to learn visual tokens in a nested manner following a coarse-to-fine order. Checkout the paper and demo.
The fundamental implementation of M3 can be found in this code snippet.
Usage and License Notices: This project utilizes certain datasets and checkpoints that are subject to their respective original licenses. Users must comply with all terms and conditions of these original licenses, including but not limited to the OpenAI Terms of Use for the dataset and the specific licenses for base language models for checkpoints trained using the dataset (e.g. Llama community license for LLaMA-2 and Vicuna-v1.5). This project does not impose any additional constraints beyond those stipulated in the original licenses. Furthermore, users are reminded to ensure that their use of the dataset and checkpoints is in compliance with all applicable laws and regulations.
Check out the details wth the load_pretrained_model function in llava/model/builder.py.
You can also use the eval_model function in llava/eval/run_llava.py to get the output easily. By doing so, you can use this code on Colab directly after downloading this repository.
model_path="mucai/llava-next-vicuna-7b-m3"prompt="What are the things I should be cautious about when I visit here?"image_file="https://llava-vl.github.io/static/images/view.jpg"args=type('Args', (), {
"model_path": model_path,
"model_base": None,
"model_name": get_model_name_from_path(model_path),
"query": prompt,
"conv_mode": None,
"image_file": image_file,
"sep": ",",
"temperature": 0,
"top_p": None,
"num_beams": 1,
"max_new_tokens": 512,
"matryoshka_vis_token_scale": 576,
})()
eval_model(args)
M3 Weights
Please check out our Model Zoo for all public M3 checkpoints, and the instructions of how to use the weights.
Demo
Gradio Web UI
To launch a Gradio demo locally, please run the following commands one by one. If you plan to launch multiple model workers to compare between different checkpoints, you only need to launch the controller and the web server ONCE.
flowchart BT
%% Declare Nodes
gws("Gradio (UI Server)")
c("Controller (API Server):<br/>PORT: 10000")
mw7b("Model Worker:<br/>llava-next-vicuna-7b-m3<br/>PORT: 40000")
mw13b("Model Worker:<br/>llava-next-vicuna-7b-m3<br/>PORT: 40001")
sglw13b("Backend:<br/>llava-v1.5-7b-m3<br/>http://localhost:30000")
lsglw13b("Worker:<br/>lllava-v1.5-7b-m3<<br/>PORT: 40002")
%% Declare Styles
classDef data fill:#3af,stroke:#48a,stroke-width:2px,color:#444
classDef success fill:#8f8,stroke:#0a0,stroke-width:2px,color:#444
classDef failure fill:#f88,stroke:#f00,stroke-width:2px,color:#444
%% Assign Styles
class id,od data;
class cimg,cs_s,scsim_s success;
class ncimg,cs_f,scsim_f failure;
subgraph Demo Connections
direction BT
c<-->gws
mw7b<-->c
mw13b<-->c
lsglw13b<-->c
sglw13b<-->lsglw13b
end
You just launched the Gradio web interface. Now, you can open the web interface with the URL printed on the screen. You may notice that there is no model in the model list. Do not worry, as we have not launched any model worker yet. It will be automatically updated when you launch a model worker.
Launch a model worker
This is the actual worker that performs the inference on the GPU. Each worker is responsible for a single model specified in --model-path.
Wait until the process finishes loading the model and you see “Uvicorn running on …”. Now, refresh your Gradio web UI, and you will see the model you just launched in the model list.
You can launch as many workers as you want, and compare between different model checkpoints in the same Gradio interface. Please keep the --controller the same, and modify the --port and --worker to a different port number for each worker.
python -m llava.serve.model_worker --host 0.0.0.0 --controller http://localhost:30000 --port <different from 40000, say 40001> --worker http://localhost:<change accordingly, i.e. 40001> --model-path <ckpt2>
If you are using an Apple device with an M1 or M2 chip, you can specify the mps device by using the --device flag: --device mps.
Launch a model worker (Multiple GPUs, when GPU VRAM <= 24GB)
If the VRAM of your GPU is less than 24GB (e.g., RTX 3090, RTX 4090, etc.), you may try running it with multiple GPUs. Our latest code base will automatically try to use multiple GPUs if you have more than one GPU. You can specify which GPUs to use with CUDA_VISIBLE_DEVICES. Below is an example of running with the first two GPUs.
Launch a model worker (4-bit, 8-bit inference, quantized)
You can launch the model worker with quantized bits (4-bit, 8-bit), which allows you to run the inference with reduced GPU memory footprint, potentially allowing you to run on a GPU with as few as 12GB VRAM. Note that inference with quantized bits may not be as accurate as the full-precision model. Simply append --load-4bit or --load-8bit to the model worker command that you are executing. Below is an example of running with 4-bit quantization.
You can train and launch the model worker with LoRA weights using our instructions here..
CLI Inference
Chat about images using LLaVA without the need of Gradio interface. It also supports multiple GPUs, 4-bit and 8-bit quantized inference. With 4-bit quantization, for our LLaVA-1.5-7B, it uses less than 8GB VRAM on a single GPU.
M3 finetunes LLaVA checkpoints using the exact same visual instruction data.
LLaVA is trained on 8 H100 GPUs with 80GB memory. To train on fewer GPUs, you can reduce the per_device_train_batch_size and increase the gradient_accumulation_steps accordingly. Always keep the global batch size the same: per_device_train_batch_size x gradient_accumulation_steps x num_gpus.
Hyperparameters
We use the exact same hyperparameters as LLaVA in finetuning. Hyperparameters used are provided below.
Hyperparameter
Global Batch Size
Learning rate
Epochs
Max length
Weight decay
LLaVA-v1.5-7B-M3
128
2e-5
1
2048
0
Download Vicuna checkpoints (automatically)
Our base model Vicuna v1.5, which is an instruction-tuned chatbot, will be downloaded automatically when you run our provided training scripts. No action is needed.
M3 Visual Instruction Tuning
Prepare data
Please download the annotation of the final mixture our instruction tuning data llava_v1_5_mix665k.json, and download the images from constituting datasets:
You may download our pretrained projectors in Model Zoo. It is not recommended to use legacy projectors, as they may be trained with a different version of the codebase, and if any option is off, the model will not function/train as we expected.
Training script with DeepSpeed ZeRO-3: finetune.sh.
If you are do not have enough GPU memory:
Use LoRA: finetune_lora.sh. We are able to fit 13B training in 8-A100-40G/8-A6000, and 7B training in 8-RTX3090. Make sure per_device_train_batch_size*gradient_accumulation_steps is the same as the provided script for best reproducibility.
Replace zero3.json with zero3_offload.json which offloads some parameters to CPU RAM. This slows down the training speed.
If you are interested in finetuning M3 model to your own task/data, please check out Finetune_Custom_Data.md。
Evaluation
We use the same benchmark as LLaVA-1.5 and LLaVA-Next
For LLaVA-NeXT on image understanding, see lmms-eval.
For LLaVA-NeXT on video understanding, see IG-VLM.
Citation
If you find LLaVA useful for your research and applications, please cite using this BibTeX:
@article{cai2024matryoshka,
title={Matryoshka Multimodal Models},
author={Cai, Mu and Yang, Jianwei and Gao, Jianfeng and Lee, Yong Jae},
journal={Proceedings of the International Conference on Learning Representation},
year={2025}
}
Acknowledgement
Vicuna: the langauge model we built upon, and our base model Vicuna-13B that has the amazing language capabilities!
LLaVa: the codebase we built upon, which has amazing multimodal abalities!
With “Programming Fundamentals”, students begin to study SoftUni’s in-house program for the comprehensive training of software engineers. The course examines fundamental concepts in programming, which are the basis for effective and quality training in the professional modules. Learners build on the knowledge gained in the Programming Basics course and begin to use more complex programming concepts and structures such as: arrays, sheets, objects and classes. Additional technologies needed by every software developer are studied, such as HTML and CSS, HTTP, bitwise operations, and more. The basics of web development are considered, as well as one of the most common technologies and tools, with which the course successfully builds an idea among students about the upcoming professional modules and knowledge, that they will acquire from them to become successful software developers.
Parable Http is a minimalist Http library used to receive requests and send responses. It is not a full implementation, offering just-enough functionality.
addHeader(string $header, string $value): void – add single header
From the HasHeaders trait:
getHeader(string $header): ?string – get a single header by string, null if non-existing
getHeaders(): string[] – get all headers
From the HasStatusCode trait:
getStatusCode(): int – the status code to be sent (i.e. 200)
getStatusCodeText(): ?string – the status code text to be sent (i.e. OK)
setStatusCode(int $statusCode): void – set the status code
Dispatcher
dispatch(Response $response): void – dispatch a Response, sending all its content as set
dispatchAndTerminate(Response $response, int $exitCode = 0): void – dispatch a Response and terminate, i.e., ending program flow immediately afterwards
Contributing
Any suggestions, bug reports or general feedback is welcome. Use github issues and pull requests, or find me over at devvoh.com.
License
All Parable components are open-source software, licensed under the MIT license.
The Polish Radio Program 3 used to shape music taste of Polish listeners. Founded in 1982 and hosted by Marek Niedzwiecki, the Charts included songs that weren’t aired by any other radio station in Poland.
This app is meant to be a time machine for all listeners of Polish Radio Program 3, allowing them to listen to the chosen chart songs once again, on Spotify.
Main functionalities
crawling through a website with the charts of Polish Radio Program 3 and scraping the data of all of them
writing web scraped data to json file
reading json file and finding a chart aired on the date chosen by an user
offering user a choice between the nearest dates, if the exact data hasn not been found but it is in the time frame of the charts airing
finding Spotify uri-s of all the songs, using multiple queries options to guarantee the best search results
creating and saving the playlist on an user’s account
Used libraries
selenium webdriver module # to serve web crawler
spotipy # to serve new playlists creation
json # to serve json files
datetime # to serve date search
dotenv # to serve virtual environment variables
pathlib # to serve files paths
logging # to provide logs
os # to serve system system files
time # to serve proper web scraping, ensuring that the entire subpages are loaded
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.