mirror of
https://github.com/transformerlab/transformerlab-app.git
synced 2025-04-14 07:48:20 +03:00
Make adaptors work and add it to run within Foundation Page
This commit is contained in:
@@ -12,6 +12,7 @@ import {
|
||||
Table,
|
||||
Typography,
|
||||
Chip,
|
||||
Modal,
|
||||
} from '@mui/joy';
|
||||
import Tooltip from '@mui/joy/Tooltip';
|
||||
import {
|
||||
@@ -21,12 +22,14 @@ import {
|
||||
Trash2Icon,
|
||||
Undo2Icon,
|
||||
XCircleIcon,
|
||||
LayersIcon,
|
||||
} from 'lucide-react';
|
||||
|
||||
import useSWR from 'swr';
|
||||
import * as chatAPI from '../../../lib/transformerlab-api-sdk';
|
||||
import ModelDetails from './ModelDetails';
|
||||
import ModelProvenanceTimeline from './ModelProvenanceTimeline';
|
||||
import ModelLayerVisualization from '../Interact/ModelLayerVisualization';
|
||||
import { useMemo, useState, useEffect } from 'react';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
|
||||
@@ -99,6 +102,7 @@ export default function CurrentFoundationInfo({
|
||||
const [embeddingModel, setEmbeddingModel] = useState(
|
||||
experimentInfo?.config?.embedding_model,
|
||||
);
|
||||
const [showVisualization, setShowVisualization] = useState(false);
|
||||
const navigate = useNavigate();
|
||||
|
||||
// Fetch base model provenance
|
||||
@@ -204,6 +208,8 @@ export default function CurrentFoundationInfo({
|
||||
});
|
||||
};
|
||||
|
||||
// console.log('ADAPTOR:', adaptor);
|
||||
|
||||
return (
|
||||
<Sheet
|
||||
sx={{
|
||||
@@ -220,6 +226,63 @@ export default function CurrentFoundationInfo({
|
||||
setFoundation={setFoundation}
|
||||
/>
|
||||
|
||||
{/* Add model visualization button */}
|
||||
<Box sx={{ display: 'flex', justifyContent: 'flex-end', mt: 1, mb: 2 }}>
|
||||
<Button
|
||||
variant="outlined"
|
||||
color="primary"
|
||||
startDecorator={<LayersIcon size={18} />}
|
||||
onClick={() => setShowVisualization(true)}
|
||||
>
|
||||
Visualize Model Architecture
|
||||
</Button>
|
||||
</Box>
|
||||
|
||||
{/* Visualization Modal */}
|
||||
<Modal
|
||||
open={showVisualization}
|
||||
onClose={() => setShowVisualization(false)}
|
||||
sx={{
|
||||
display: 'flex',
|
||||
justifyContent: 'center',
|
||||
alignItems: 'center',
|
||||
}}
|
||||
>
|
||||
<Sheet
|
||||
sx={{
|
||||
width: '90%',
|
||||
height: '90%',
|
||||
borderRadius: 'md',
|
||||
overflow: 'hidden',
|
||||
p: 0,
|
||||
}}
|
||||
>
|
||||
<Box
|
||||
sx={{
|
||||
display: 'flex',
|
||||
justifyContent: 'space-between',
|
||||
alignItems: 'center',
|
||||
p: 2,
|
||||
borderBottom: '1px solid',
|
||||
borderColor: 'divider',
|
||||
}}
|
||||
>
|
||||
<Typography level="title-md">
|
||||
Model Architecture: {experimentInfo?.config?.foundation}
|
||||
</Typography>
|
||||
<IconButton onClick={() => setShowVisualization(false)}>
|
||||
<XCircleIcon />
|
||||
</IconButton>
|
||||
</Box>
|
||||
<Box sx={{ height: 'calc(100% - 60px)' }}>
|
||||
<ModelLayerVisualization
|
||||
currentModel={experimentInfo?.config?.foundation}
|
||||
currentAdaptor={adaptor}
|
||||
/>
|
||||
</Box>
|
||||
</Sheet>
|
||||
</Modal>
|
||||
|
||||
<Sheet sx={{ overflow: 'auto' }}>
|
||||
<Box sx={{ mt: 3 }}>
|
||||
<Typography level="title-lg" marginBottom={1}>
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,19 +0,0 @@
|
||||
def generate_architecture(model_name):
|
||||
model = AutoModelForCausalLM.from_pretrained(model_name)
|
||||
state_dict = model.state_dict()
|
||||
cube_list = []
|
||||
unique_layers = sorted(set(clean_layer_name(layer) for layer in state_dict.keys()))
|
||||
max_param_size = max(v.numel() for v in state_dict.values())
|
||||
min_param_size = min(v.numel() for v in state_dict.values())
|
||||
min_size = 0.5
|
||||
max_size = 2.0
|
||||
for layer, params in state_dict.items():
|
||||
param_size = params.numel()
|
||||
size = float(min_size + ((np.log(param_size) - np.log(min_param_size)) / (np.log(max_param_size) - np.log(min_param_size))) * (max_size - min_size))
|
||||
clean_name = clean_layer_name(layer)
|
||||
cube_list.append({
|
||||
'name': clean_name,
|
||||
'size': size,
|
||||
'param_count': param_size,
|
||||
})
|
||||
return cube_list
|
||||
Reference in New Issue
Block a user